If you are not using NSApplicationMain()
NSInitializeProcess(argc,argv) must to be called before any Objective-C in main() as it initializes the Objective-C runtime and the command line in NSProcessInfo.
int main(int argc, const char *argv[]) {
NSInitializeProcess(argc,argv);
// ... rest of program ...
}
and of course sadly we typically have to use #ifdef's
int main(int argc, const char *argv[]) {
#ifndef __APPLE__
NSInitializeProcess(argc,argv);
#endif
// ... rest of program ...
}
If you are using NSApplicationMain like so:
int main(int argc, const char *argv[]) {
return NSApplicationMain(argc, argv);
}
You don't need to use NSInitializeProcess as NSApplicationMain calls NSInitializeProcess.
While I would agree this this is not the most transparent way of initializing the command line arguments it saves the hassle of maintaining custom C runtime initialization for each platform.
