Where is stdarg.h?

sidyll picture sidyll · Jul 15, 2011 · Viewed 9.4k times · Source

On my system (Mac OS 10.6) /usr/include/stdarg.h is:

/* This file is public domain.  */
/* GCC uses its own copy of this header */
#if defined(__GNUC__)
#include_next <stdarg.h>
#elif defined(__MWERKS__)
#include "mw_stdarg.h"
#else
#error "This header only supports __MWERKS__."
#endif

So, if GCC uses its own copy of stdarg.h, where is it? I have no idea on what that #include_next means (maybe a GCC extension?), nor something about "MWERKS" (a compiler?).

Answer

Stephen Canon picture Stephen Canon · Jul 15, 2011

<stdarg.h>, even more than most C library headers, tends to be very compiler-specific. As such, each of the compilers on OS X has it's own stdarg.h implementation, found in a compiler-specific location (which is included as part of the default search paths for that compiler). The compiler finds the generic stdarg.h, which basically tells it to "keep looking" (via the extension #include_next), and it then finds the compiler-specific implementation.

__MWERKS__ refers to an old compiler for PPC, "MetroWerks CodeWarrior".