Undefined Reference to a function

后端 未结 5 796
说谎
说谎 2020-12-18 10:34

I\'m using Linux and I have the following files:

main.c, main.h
fileA.c, fileA.h
fileB.cpp, fileB.h

The function F1() is decla

5条回答
  •  猫巷女王i
    2020-12-18 10:46

    To be able to call a c++ function from c source code you neeed to give the appropriate linkage specification.

    The format for specifying linkage specification is

    extern "type_of_Linkage" 
    

    So in your case, you should be using:

    extern "C" void F1();
    

提交回复
热议问题