Unknown class name when mixing Objective-C and C ++

It drives me crazy.

I have a C ++ class declaration in the file foo.h.

class foo // error marks are here
{
};

When I have #include/#importthis header in my fooUser.mm file , it compiles. When I do fooUser.h#include/#import in my file , this is not the case, and there are compiler errors.

Unknown type name 'class'; did you mean 'Class'?
Excpected ';' after top level declarator.

I am using Xcode 4.2, LLVM 3.0 compiler, ... this should be important.

+4
source share
1 answer

, "fooUser.h" , ++, . , " ", .

++ , (Objective-) ++.

++

#ifdef __cplusplus
// …
#endif
+6

Source: https://habr.com/ru/post/1528909/


All Articles