Is it pointless to have:
#ifdef __cplusplus
extern "C" {
#endif
// code...
#ifdef __cplusplus
}
#endif
Where "code..." is just a bunch of defines and typedefs (no includes, etc.)?
Is it pointless to have:
#ifdef __cplusplus
extern "C" {
#endif
// code...
#ifdef __cplusplus
}
#endif
Where "code..." is just a bunch of defines and typedefs (no includes, etc.)?
In principle, in your particular case (no variable or function declaration), the extern "C"
is pointless.
In practice, it makes the code more readable (showing the intent of defining a C++ friendly interface) and less brittle. Some developer (perhaps you) might (in a few months) add other declarations inside it.
It depends on how you intend the header to be used.
If the types and values are valid and have the same meaning in both C and C++, and you intend to use them from some compilation units compiled as C and others compiled as C++, then you need to use extern "C"
when compiling as C++. Otherwise, your C++ code and C code cannot interoperate.
If the header file is included by compilation units will only ever be built as C, as C++, but never as both, then you don't need extern "C"
. And you can use features specific to your chosen language.