The project uses objects of C and C++. That arrangement to work, you must encapsulate ads With functions in extern "C" {...}.
I usually do it in header module
// my_c_header.h
#ifdef __cplusplus
extern "C" {
#endif
void spam(void);
#ifdef __cplusplus
}
#endif
and safely include the header in C++ file.
However, in the project meet type design
// my_cpp_header.hpp
extern "C" {
#include "my_c_header.h"
}
...
In this case, the my_c_header.h it is not spelled out.
To me it looks unsafe, as my_c_header.h can be included somewhere previously without extern "C" around, then the inclusion above will be ineffective. Well, in General the widespread use of extern "C" {} around the #include looks heavy.
What do you think about this? How do you prevent C and C++ in their projects?
However, Your message is valid. Especially if Ssny code was written a long time without thinking about what it will be used in other projects. Thank you! - Delpha_Cummings commented on July 9th 19 at 11:38