<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 17, 2014 at 11:44 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There is no c++ mangling with variables (or is there) so what does the extern “C” buy us? or mean?</blockquote><div><br></div><div>You use extern "C" to indicate that something was defined in a C compilation unit (source file compiled using a C compiler).  Compilers are usually pretty generous (I'm looking at you GCC) in letting you access symbols from C compilation units without the extern "C", but it is still undefined behavior to access any C symbols (variables, functions, etc...) from a C++ compilation unit without it.<br><br></div><div>Variables can be mangled if, for example, they are declared within a namespace.  If that header is included from within a namespace declaration in a C++ source file and is not properly escaped, you could end up with a locally scoped namespace reference to a PETSc variable, which would break all sorts of things.<br><br>A<br></div></div></div></div>