This is driving me crazy.
I have a C++ class declaration in foo.h file.
class foo // error marks are here
{
};
When I #include/#import
this header in my fooUser.mm file, it compiles. When I do #include/#import
it in my fooUser.h file it doesn't, and the compiler errors are.
Unknown type name 'class'; did you mean 'Class'?
Excpected ';' after top level declarator.
I'm using XCode 4.2, LLVM compiler 3.0,... should this be important.
As you said in a comment, "fooUser.h" is included from non-C++ files as well, and that causes the compiler error. Header files are not compiled separately, but as part of the "compilation unit" from which they are included.
You should try to separate the C++ declarations into a header file that is included only from (Objective-)C++ files.
As a workaround, you could also protect the C++ declarations by
#ifdef __cplusplus
// …
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With