1

Exactly like How do I find the location of the executable in C? but for Mac OS X. I am aware that argv[0] probably works, but I want a way to programmatically access this information (i.e. a function call) as the code I am writing is part of a library which does not have access to argv[0].

Community
  • 1
  • 1
chacham15
  • 13,719
  • 26
  • 104
  • 207

1 Answers1

3

Mac OS X implements the functions:

int _NSGetExecutablePath(char * buf, uint32_t * length);
int * _NSGetArgc(void);
char *** _NSGetArgv(void);

The first of these is probably what you want here. The other two are interesting as well, though!