How does C's “extern” work?

后端 未结 7 1523
轻奢々
轻奢々 2020-12-28 10:56

I have a C/C++ program that\'s a plugin to Firefox. Because it\'s a plugin, it has non-main entry points. Those entrypoints need to be compiled in C because otherwise they g

7条回答
  •  清酒与你
    2020-12-28 11:33

    Only the declaration of the functions needs to be wrapped in extern "C". Once the function has been declared, the compiler knows that its name shouldn't be mangled. Since most of the time your function declarations are in your header file, wrapping the extern "C" around your header or around the include of it should work fine.

提交回复
热议问题