extern "C"与extern "C" { … }的差别

There are two different forms of the extern "C" declaration: extern "C" as used above, and extern "C" { … } with the declarations between the braces. The first (inline) form is a declaration with extern linkage and with C language linkage; the second only affects language linkage. The following two declarations are thus equivalent:

extern "C" int foo;
extern "C" void bar();

and

extern "C" {
     extern int foo;
     extern void bar();
}

As there is no difference between an extern and a non-extern function declaration, this is no problem as long as you are not declaring any variables. If you declare variables, keep in mind that

extern "C" int foo;

and

extern "C" {
    int foo;
}

are not the same thing.

摘自:http://tldp.org/HOWTO/C++-dlopen/thesolution.html

原文地址:https://www.cnblogs.com/opangle/p/3133546.html