#include /* * http://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html * * C99 gcc(1) gcc(2) * Intel cc 5.0 x x x * CC Sun 2.1 - - - * cc Sun WS 5 - - - * Compaq C V6.x - - - * HP C 11.01 - - - * gcc 2.7.2.f.1 - x - * gcc 2.8.1 - x - * gcc 2.96 x x x * gcc 3.0.4 x x x * MIPS Pro 7 - - - */ #ifdef USE_C99 #define debugc99(format, ...) fprintf (stderr, format, __VA_ARGS__) #endif #if (defined __GNUC__ ) || (defined DEBUG1) #define debug(format, args...) fprintf (stderr, format, args) #ifndef DEBUG1 #define DEBUG1 1 #endif #endif #if ((defined __GNUC__) && ( ( __GNUC_MINOR__ > 8 ) || ( __GNUC__ > 2 ))) || (defined DEBUG2 ) #ifndef DEBUG2 #define DEBUG2 1 #endif #define debug2(format, ...) fprintf (stderr, format, ## __VA_ARGS__) #endif int main(void) { printf("Hello, World!\n"); #ifdef __GNUC__ printf("gcc %d.%d\n",__GNUC__,__GNUC_MINOR__); #endif #ifdef DEBUG1 debug("%d\t%s\n",__LINE__,"Hola"); #endif #ifdef DEBUG2 debug2("%d\t%s\n",__LINE__,"Hola"); #endif #ifdef USE_C99 debugc99("%d\t%s\n",__LINE__,"Hola"); #endif /* Next line will cause a cpp error, since it should end with an argument */ /* debug("Hola");*/ #ifdef DEBUG1 debug("Hola\n",""); #endif #ifdef DEBUG2 debug2("Hola\n"); #endif return(0); }