12

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

sidyll
  • 57,726
  • 14
  • 108
  • 151
  • 1
    MWERKS is probably MetroWerks CodeWarrior - now from [Freescale](http://www.freescale.com/webapp/sps/site/homepage.jsp?code=CW_HOME) – Steve Fallows Jul 15 '11 at 20:02
  • MWerks is or was MetroWerks Code Warrior not sure how to find the order of includes – Grady Player Jul 15 '11 at 20:08
  • 4
    `gcc -v -E - < /dev/null > /dev/null` prints, among other things, the list of directories that gcc will search for header files. – zwol Jul 15 '11 at 20:08
  • @Steve Fallows: Thanks! Hmm, old material. Probably not included in Lion. – sidyll Jul 15 '11 at 20:08
  • Thanks Zack, I used `\`gcc -print-prog-name=cc1\` -v` to do it, seems to print only what's needed (include paths) – sidyll Jul 15 '11 at 20:11
  • 1
    @Steve Fallows, @Grady Player and @Zack: Thanks for the helpful comments! And @Stephen Canon, @cnicutar and @Anomie: After your `#include_next` clues I found the header. Now it will be a problem to accept an answer. – sidyll Jul 15 '11 at 20:13
  • 3
    wow... I have the exact same problem... Can i ask you how did you resolve it... I am having that issue when i am using Lion. trying to install python-mysqldb. Thanks... Rajesh,. – medampudi Nov 05 '11 at 18:42

2 Answers2

6

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

Stephen Canon
  • 103,815
  • 19
  • 183
  • 269
3

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

Anomie
  • 92,546
  • 13
  • 126
  • 145