长路漫漫

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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

posted on 2013-06-13 10:06  opangle  阅读(372)  评论(0编辑  收藏  举报