On Wed, Sep 17, 2014 at 11:44 PM, Barry Smith <[email protected]> wrote:
> There is no c++ mangling with variables (or is there) so what does the > extern āCā buy us? or mean? 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. 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. A
