In C, I can do this to have an unspecified number of arguments in a function:
#include <elf.h>
#include <stddef.h>
#include <stdlib.h>
extern char **__environ;
int __libc_start_main
(
int (*main)(),
int argc,
char **argv
)
{
int ret;
Elf32_auxv_t *auxv;
size_t aux[38];
/* ... */
exit(main(argc, argv, __environ, aux));
}
However, when doing this in C++, the compiler emits this error:
test.c: In function ‘int __libc_start_main(int (*)(), int, char**)’:
test.c:21:45: error: too many arguments to function
exit(main(argc, argv, __environ, aux));
^
How do I do this in C++?
I understand that the C/C++ standards don't allow this, but I'm currently writing an implementation of the standard C library.