I have a project that is mixing C and C++. In a C header file, I have code like this:
typedef struct mystruct* mystruct;
struct mystruct {
// whatever struct needs
};
And to use this in the C++ file, I am doing:
extern "C" {
#include "mystruct.h"
}
So you see that I am creating an opaque pointer using the same names. This is fine in C but not in C++ (because of the requirement to instantiate using the struct keyword in C but not in C++). However, I get an error (conflicting declarations) when trying to compile the C++ code. I thought that using the extern "C"
would make the compiler treat the C header as C, but it seems to still be using it as C++. Is there any explanation for what is happening here?