iPhone/iPad fatal error in C++ code produces no output in the log
I'm trying to move away from Objective-C to C++ for audio in my iPad programming, due to the a few reports I've heard of Objective-C selectors sometimes causing audio glitches. So I'm starting to use pure C++ files.
When a fatal error happens in one of the C++ files, I get no output f开发者_如何学编程rom the log. The app just crashes.
For example, if I do this in my C++ file:
env = new ADSR();
cout << "setting env to null\n";
env = NULL;
env->setSustainLevel(1);
cout << "called function on non-initialized env\n";
I get the following output:
setting env to null
After that, there's a method called on NULL, which apparently kills the app, but absolutely nothing to that effect is reported. What do I need to do to have useful information logged when there's an error in my C++ code?
Have you tried using breakpoints and tracing the game flow using the Debugger? I think using these would definitely give some log!!
There are a few things you can try.
You can set NSZombie to
enabled
.Perhaps you can link your file against Foundation Framework and use NSLog to debug the crash.
Also, if you compile to a device, you can check the Device Console and the Error Logs in Xcode's Organizer.
The mac's console app provides great information on why my crash happened. Thanks to Moshe for getting me most of the way there by suggesting I look at the console if I was running the app on a device.
精彩评论