I just got some C code that uses extern "C" to declare external functions like this:
extern "C" void func();
Is this valid C? I'm getting an error at this line, but I'm not sure if it's because of this or something else.
c++extern-c
I just got some C code that uses extern "C" to declare external functions like this:
extern "C" void func();
Is this valid C? I'm getting an error at this line, but I'm not sure if it's because of this or something else.
Best Answer
No, it's not valid C. It should only be used in C++ code to refer to functions defined in C code. The
extern "C"
should be surrounded in aifdef __cplusplus
/#endif
block: