iDevGames Forums
How can I use NSLog inside a CPP file? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: How can I use NSLog inside a CPP file? (/thread-1990.html)



How can I use NSLog inside a CPP file? - riruilo - Dec 27, 2008 08:59 AM

Hi friends!

How can I use NSLog inside a CPP file? I mean, should I include or import any file? and How I send to it a string?

Thanks a lot for your help.


How can I use NSLog inside a CPP file? - ThemsAllTook - Dec 27, 2008 09:57 AM

By renaming to file to .mm, or using printf/cout instead. NSLog requires NSString, which requires an Objective-C compilation mode. The .mm extension allows you to compile as Objective-C++.


How can I use NSLog inside a CPP file? - riruilo - Dec 27, 2008 04:30 PM

ThemsAllTook Wrote:By renaming to file to .mm, or using printf/cout instead. NSLog requires NSString, which requires an Objective-C compilation mode. The .mm extension allows you to compile as Objective-C++.

Thanks! I didn't know printf could work. Thanks a lot.

Edit: It seems only works on the simulator, but not when I launch the app on my iPhone. Do you all have the same problem? Any idea?
Thanks.


How can I use NSLog inside a CPP file? - AnotherJake - Dec 27, 2008 05:08 PM

riruilo Wrote:Edit: It seems only works on the simulator, but not when I launch the app on my iPhone. Do you all have the same problem? Any idea?
Thanks.

In what way does it not work on the iPhone?

Are you getting build errors, or are you not getting console output in Xcode as you expect?

Are you building for distribution or debug?

Are you launching the app from the iPhone, or launching the app from Xcode?

[edit] I ask because the only way I ever see console output from the iPhone in Xcode is build for debug and launch from Xcode. Otherwise you have to look at the console tab in the organizer to see the output.


How can I use NSLog inside a CPP file? - riruilo - Dec 28, 2008 04:25 AM

AnotherJake Wrote:In what way does it not work on the iPhone?

Are you getting build errors, or are you not getting console output in Xcode as you expect?

Are you building for distribution or debug?

Are you launching the app from the iPhone, or launching the app from Xcode?

[edit] I ask because the only way I ever see console output from the iPhone in Xcode is build for debug and launch from Xcode. Otherwise you have to look at the console tab in the organizer to see the output.


OK. Now it is working perfectly, thanks a lot!