startup getmainargs

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
nullplan
Member
Member
Posts: 1903
Joined: Wed Aug 30, 2017 8:24 am

Re: startup getmainargs

Post 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.
Carpe diem!
Post Reply