Accessing non-existing varargs argument

Florian Weimer fweimer@redhat.com
Fri Dec 12 10:20:00 GMT 2014


open is declared as:

   int open(const char *pathname, int flags, ...);

The intent is to have two overloaded variants:

   int open(const char *pathname, int flags);
   int open(const char *pathname, int flags, mode_t mode);

The presence of the mode argument depends on the flags specified.  The 
set of such flags is known by the kernel.  I wish to avoid to maintain 
this implementation detail in libc as well, so I want to always read the 
mode argument, possibly passing a garbage value to the kernel.

Is there GCC-portable way to achieve this?

-- 
Florian Weimer / Red Hat Product Security



More information about the Gcc-help mailing list