Jump to content
  • Advertisement
Sign in to follow this  
taby

C++ problem with Objective C.

This topic is 754 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can't #include <iostream> because it gives me an error "Expected unqualified-id".

 

Anyone have any experience with this?

Share this post


Link to post
Share on other sites
Advertisement

<iostream> is a C++ header. Objective-C is based on C, not C++. So the C++ constructs in a C++ header are unintelligible and will cause compiler errors.

 

 

You can build your Cocoa projects in Objective-C++ instead, this will let you include C++ headers. If you're using Xcode this is as simple as changing the file extensions from .m to .mm.

Share this post


Link to post
Share on other sites

Indeed, the problem was that one of the .m files had to be renamed to .mm.

 

Now I'm getting linker problems:

 

Showing Recent Issues
(null): "_OBJC_CLASS_$_GLKViewController", referenced from:
(null): _OBJC_CLASS_$_GameViewController in GameViewController.o
(null): "_OBJC_METACLASS_$_GLKViewController", referenced from:
(null): _OBJC_METACLASS_$_GameViewController in GameViewController.o
(null): Symbol(s) not found for architecture x86_64
(null): Linker command failed with exit code 1 (use -v to see invocation)
 
 
Edit: I fixed it by renaming one of the .mm files to .m. :)
Edited by sjhalayka

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!