How does C's “extern” work?

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

    It is already enough when you only extern "C" the entities you need to be externally visible. You can make a standard cc/cpp/cxx/... file, but cherry pick C-names:

    class Foo {};
    
    extern "C" int someInterfaceFun () {
        Foo foo;
        return 0xFEED;
    }
    

提交回复
热议问题