Is there an inline way to mix c and c++ prototypes?

c, c++

Solution

It's easier than you think.

#ifdef __cplusplus
#define IS_C(x)   extern "C" x ;
#define IS_CPP(x) x ;
#else
#define IS_C(x)   x ;
#define IS_CPP(x) 
#endif

With this type of header:

IS_C   (void ArrayList_insert(ArrayList *arrlst, void *data, int i))
IS_CPP (void ArrayList_insert(ArrayList *arrlst, char *data, int i))
IS_CPP (void ArrayList_insert(ArrayList *arrlst, Buffer *data, int i))

Problem

I want an inline way of specifying which prototypes should be included with c++. For example: ``` void ArrayList_insert(ArrayList *arrlst, void *data, int i); IS_CPP void ArrayList_insert(ArrayList *arrlst, char *data, int i); IS_CPP void ArrayList_insert(ArrayList *arrlst, Buffer *data, int i); ``` currently I am doing: ``` #ifdef __cplusplus extern "C" { #endif ....C HEADERS.. #ifdef __cplusplus } ....C++ HEADERS... #endif ``` but its very inconvenient because overloads of the same function are in different places. I could just have 2 different header files, but that is a pain too. Therefore, Im looking for an inline solution like i proposed above. Does anyone know of a way to do that?

Original source