What is the /proc/self/cmdline / GetCommandLine equivalent on Mac OS X?

一个人想着一个人 提交于 2019-12-12 11:19:11

问题


How can I access the command line on Mac OS X without using argc, argv? On Linux, I would simply read /proc/self/cmdline or use GetCommandLine on Windows, but I can't find the equivalent for Mac OS X.


回答1:


There are functions called _NSGetArgv and _NSGetArgc in crt_externs.h. However, wouldn't it be simpler to just store the argc/argv in a variable at the start of main and be portable to all three platforms?

NOTE: These functions are not directly documented, but they are mentioned in the documentation for NSApplicationMain in the Application Kit Functions Reference, and the related _NSGetEnviron is mentioned in the environ(7) manpage.



来源:https://stackoverflow.com/questions/11938327/what-is-the-proc-self-cmdline-getcommandline-equivalent-on-mac-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!