Including C / C ++ Headers in Xcode 4

I used the C ++ library without problems for projects built using Xcode 3, but now I am having problems building projects built using Xcode 4.

Drop the library into the Xcode 4 project and it builds fine, but as soon as I #include , I get the error "Lexical or Preprocessor Issue", more specifically the "line file" is not found, in line 4 of its main header file.

On closer inspection, the error indicates that the 'string' file not found in ~/my project directory/include/mainheader.h

I tried the listed solutions here , but no one worked.

So he thinks the header file is in my project directory, but this is obviously the C / C ++ header ... How can I tell Xcode to look for these C / C ++ headers?

+4
source share
2 answers

The problematic #include was at the top of my ViewController.mm , which I had already turned into Objective-C ++, specifying it .mm as its extension. But ViewController.mm is eventually imported by AppDelegate.m , which defaults to Objective-C, and I forgot to make it Objective-C ++, hence the problem.

So, renaming AppDelegate.m to AppDelegate.mm solved the problem.

+12
source

I think #include is a C ++ class template. You need to use the std namespace in the header file, and also rename the source .m file format to .mm format.

it works for me :) try this ...

0
source

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


All Articles