The C99 and C11 draft standards allow for implementation defined set of parameters to main
, these parameters are going to be specific to those systems(non-portable). From section 5.1.2.2.1
:
[...]or in some other implementation-defined manner[...]
The only additional parameters I can find documented are envp
and apple
, we can find a good description in Wikipedia's C and C++ section on Entry Points:
Other platform-dependent formats are also allowed by the C and C++
standards, except that in C++ the return type must always be int;[6]
for example, Unix (though not POSIX.1) and Microsoft Windows have a
third argument giving the program's environment, otherwise accessible
through getenv in stdlib.h:
int main(int argc, char **argv, char **envp);
Mac OS X and Darwin have a fourth parameter containing arbitrary
OS-supplied information, such as the path to the executing binary:[7]
int main(int argc, char **argv, char **envp, char **apple);
It looks like Windows has a Microsoft specific wmain which takes wchar_t
:
int wmain(int argc, wchar_t *argv[], wchar_t *envp[]);
argc
andargv
are implementation defined and will be specific to the particular systems. – Cupritemain()
return in C and C++? which covers this issue too, though it seems not to have an x-ref to thechar **apple
argument mentioned by Shafik Yaghmour. – Unterwalden