Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is stdarg.h?

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?).

like image 810
sidyll Avatar asked Jul 15 '11 19:07

sidyll


People also ask

What is Stdarg H header file is used for?

The stdarg. h header file defines macros used to access arguments in functions with variable-length argument lists. The stdarg. h header file also defines the structure va_list .

Which header file contains Va_list?

h header file to extract the values stored in the variable argument list--va_start, which initializes the list, va_arg, which returns the next argument in the list, and va_end, which cleans up the variable argument list.

What is a Va_list?

va_list is a complete object type suitable for holding the information needed by the macros va_start, va_copy, va_arg, and va_end. If a va_list instance is created, passed to another function, and used via va_arg in that function, then any subsequent use in the calling function should be preceded by a call to va_end.


2 Answers

<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".

like image 78
Stephen Canon Avatar answered Nov 07 '22 17:11

Stephen Canon


#include_next is a gcc extension. As you should know, #include has a list of paths it searches for header files. #include_next tells the preprocessor to include the specified header checking only paths in the list after the one that contained the current header file.

__MWERKS__ is a preprocessor macro defined on old versions of CodeWarrior.

like image 35
Anomie Avatar answered Nov 07 '22 18:11

Anomie