NSLog on .mm file
How do I print out something to the debugger console if the file is of .mm extension?
I开发者_运维百科 tried NSLog
and printf
but none shows anything on the debugger console.
NSLog works just fine in .mm files, as well as printf. Even std::cout << "foo";
works great in .mm files because the extension marks the files as Objective-C++ file so you can mix C, C++ and ObjC in there.
If it doesn't print anything out, make sure that the program really reaches the point where you set the NSLog
, you can place a few break points for this and then single step through your program.
Your problem has nothing to do with the type of the compilation unit (".mm" for Objective-C++ or ".m" for pure Objective-C). NSLog
as well as printf
work in both languages.
Your problem is elsewhere.
Try importing <Foundation/Foundation.h>
Add this line in the top of your class, this might help.
#import <Foundation/Foundation.h>
精彩评论