C header file won't compile with C, but will with C++.
- by Leif Andersen
I have the following chunk of a header file BKE_mesh.h:
/* Connectivity data */
typedef struct IndexNode {
struct IndexNode *next, *prev;
int index;
} IndexNode;
void create_vert_face_map(ListBase **map, IndexNode **mem, const struct MFace *mface,
const int totvert, const int totface);
void create_vert_edge_map(ListBase **map, IndexNode **mem, const struct MEdge *medge,
const int totvert, const int totedge);
Note that the header file was prepared for the possibility of being used in a C++ file, as it had:
#ifdef __cplusplus
extern "C" {
#endif
at the top of the file, and the needed finish at the bottom. But the class implementing it was written in C.
Next, whenever I try to #include the header file, I get an odd error. If the file has a .cpp extension, it compiles just fine, no complaints whatsoever. However, if I do:
#include "BKE_mesh.h"
inside of a file with a .c extension, I get the following errors:
expected ')' before '*' token
for the two last functions, in specific, the variable:
ListBase **map
in both classes. (Note that earlier in the header file, it declared, but not defined ListBase).
So, my question is: why is this valid C++ code, but not C code?
Thank you.