How does C's “extern” work?

后端 未结 7 1539
轻奢々
轻奢々 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:30

    This is not a kludge - this is how C/C++ compilers work. When the compiler compiles a file that uses your library, it checks the .h files for declarations of functions and globals. Hence, you wrap the .h files with extern "C" to avoid name mangling.

提交回复
热议问题