在Mac OS X上,/proc/self/cmdline/GetCommandLine等效项是什么? [英] What is the /proc/self/cmdline / GetCommandLine equivalent on Mac OS X?

查看:357
本文介绍了在Mac OS X上,/proc/self/cmdline/GetCommandLine等效项是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不使用argc,argv的情况下访问Mac OS X上的命令行?在Linux上,我只读/proc/self/cmdline或在Windows上使用GetCommandLine,但找不到与Mac OS X等效的文件.

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.

推荐答案

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.

这篇关于在Mac OS X上,/proc/self/cmdline/GetCommandLine等效项是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆