Page 2 of 2

Re: startup getmainargs

Posted: Mon Jun 23, 2025 11:29 am
by nullplan
kerravon wrote: Mon Jun 23, 2025 5:25 am If the compiler uses - or can use - stack calling convention, then:

#define va_arg(ap, type) *(type *)(ap += sizeof(type), ap - sizeof(type))
Wow, such portable! It doesn't work on any platform I know except i386.
kerravon wrote: Mon Jun 23, 2025 5:25 am My application suite doesn't pass "short",
That is no issue because the type given to va_arg must be a promoted type, i.e. int or bigger. GCC warns me that executing va_arg(ap, short) will abort at run time.