aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/commandline.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-11-03 15:50:19 +0100
committerGitHub Enterprise <[email protected]>2025-11-03 15:50:19 +0100
commit43f70003c9c3e38dddff49c873ce34fde2923abe (patch)
treecff2471d5209225a553d85afff903fb68827b406 /src/zencore/commandline.cpp
parentVarious fixes to address issues flagged by gcc / non-UE toolchain build (#621) (diff)
downloadzen-43f70003c9c3e38dddff49c873ce34fde2923abe.tar.xz
zen-43f70003c9c3e38dddff49c873ce34fde2923abe.zip
added MacOS-native IterateCommandlineArgs (#624)
fixes issue where command line arguments to control tracing would not work on Mac
Diffstat (limited to 'src/zencore/commandline.cpp')
-rw-r--r--src/zencore/commandline.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/zencore/commandline.cpp b/src/zencore/commandline.cpp
index 0cdccf986..78260aeef 100644
--- a/src/zencore/commandline.cpp
+++ b/src/zencore/commandline.cpp
@@ -10,6 +10,10 @@ ZEN_THIRD_PARTY_INCLUDES_START
ZEN_THIRD_PARTY_INCLUDES_END
#endif
+#if ZEN_PLATFORM_MAC
+# include <crt_externs.h>
+#endif
+
#include <functional>
namespace zen {
@@ -35,7 +39,17 @@ IterateCommandlineArgs(std::function<void(const std::string_view& Arg)>& Process
}
::LocalFree(HLOCAL(ArgV));
-#elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
+#elif ZEN_PLATFORM_MAC
+ int ArgC = *_NSGetArgc();
+ char** ArgV = *_NSGetArgv();
+ if (ArgC > 1)
+ {
+ for (int i = 1; i < ArgC; ++i)
+ {
+ ProcessArg(ArgV[i]);
+ }
+ }
+#elif ZEN_PLATFORM_LINUX
if (FILE* CmdLineFile = fopen("/proc/self/cmdline", "r"))
{
const char* ArgV[255] = {};