Answer the question
In order to leave comments, you need to log in
What is the correct way to use extern "C"?
The project uses C and C++ objects. For linking to work, it is necessary to encapsulate C function declarations in extern "C" {...}.
I usually do this in the header of the C module
// my_c_header.h
#ifdef __cplusplus
extern "C" {
#endif
void spam(void);
#ifdef __cplusplus
}
#endif
// my_cpp_header.hpp
extern "C" {
#include "my_c_header.h"
}
...
Answer the question
In order to leave comments, you need to log in
However, in the project I encounter constructions of the typeIt is right. These parts of the project are written in C and are meant to be used in C.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question