C code compiled with C++: undefined reference

前端 未结 4 1099
攒了一身酷
攒了一身酷 2021-02-15 00:00

I have a small program that I can compile with GCC and ICC without any difficulties, but I would also like the code to work with G++ and ICPC. I tried to add this:



        
4条回答
  •  遥遥无期
    2021-02-15 00:09

    You get undefined references because the declaration and the definition are not matching if you put extern "C", which prevents name mangling from happening: but in this case this is happening only in your header files.

提交回复
热议问题