Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
就像我如何在 C 中找到可执行文件的位置?但对于 Mac OS X。我知道 argv[0] 可能有效,但我想要一种以编程方式访问此信息(即函数调用)的方法,因为我正在编写的代码是无法访问的库的一部分参数 [0]。
Mac OS X 实现了以下功能:
int _NSGetExecutablePath(char * buf, uint32_t * length); int * _NSGetArgc(void); char *** _NSGetArgv(void);
其中第一个可能是您想要的。不过,另外两个也很有趣!