Linking C from C++ in OS X Mavericks

后端 未结 3 1121
温柔的废话
温柔的废话 2021-01-04 17:51

Having transitioned to OS X Mavericks and XCode 5.0.1, I can no longer gracefully link compiled C files (output from gcc) to a C++ project (output from g++).

The off

3条回答
  •  执笔经年
    2021-01-04 18:52

    Most probably you are a victim of Name mangling. To avoid name mangling in C++, use extern "C" around declarations, like:

    #ifdef __cplusplus 
    extern "C" {
    #endif
        void load_dmat(char const*);
    #ifdef __cplusplus
    }
    #endif
    

提交回复
热议问题