Mail Archives: djgpp/2002/12/05/08:51:38
On Wednesday 04 December 2002 16:38, Keen Wayne A Contr AFRL/MNGG wrote:
> You got my curiosity up, so I checked the same operation on Cygwin. I got
> a similar result, PATCHLEVEL appears not to be defined. On the other hand,
> I was able to use __VERSION__ to get the right result. I took the liberty
> of tacking onto your code.
>
> As a side note, WHY can I never remember %s is the format string for
> string. What a moron I am.
>
> #include <stdio.h>
> #include <iostream>
> using namespace std;
>
> int
> main (void)
> {
> char buf[30], *p = buf;
>
> p += sprintf (p, "gcc %d.%d %s", __GNUC__, __GNUC_MINOR__,__VERSION__);
>
> #if defined(__GNUC_PATCHLEVEL)
> p += sprintf (p, ".%d", __GNUC_PATCHLEVEL);
> cout << "Yes, I am defined\n";
> #endif
>
> puts (buf);
> return (0);
> }
>
Why so complicated?
gcc -dM -E -x c /dev/null
will show all default defines for C. Similary using '-x c++' instead of '-x c'
You get the same about C++.
Here is what I'm getting for DJGPP (-x c)
#define __HAVE_BUILTIN_SETJMP__ 1
#define __unix__ 1
#define unix 1
#define __i386__ 1
#define __SIZE_TYPE__ long unsigned int
#define __GNUC_PATCHLEVEL__ 1
#define __DJGPP 2
#define __USER_LABEL_PREFIX__ _
#define __tune_pentium__ 1
#define __STDC_HOSTED__ 1
#define __MSDOS__ 1
#define DJGPP 2
#define __WCHAR_TYPE__ short unsigned int
#define __DJGPP__ 2
#define __WINT_TYPE__ int
#define __GNUC__ 3
#define __tune_i586__ 1
#define __DJGPP_MINOR__ 4
#define __GXX_ABI_VERSION 102
#define __GO32__ 1
#define i386 1
#define GO32 1
#define __GNUC_MINOR__ 2
#define DJGPP_MINOR 4
#define __STDC__ 1
#define __PTRDIFF_TYPE__ int
#define MSDOS 1
#define __DJGPP_MINOR 4
#define __REGISTER_PREFIX__
#define __NO_INLINE__ 1
#define __i386 1
#define __VERSION__ "3.2.1"
and also under Linux:
bash-2.05b$ gcc -dM -E -x c /dev/null
#define __HAVE_BUILTIN_SETJMP__ 1
#define __unix__ 1
#define unix 1
#define __i386__ 1
#define __SIZE_TYPE__ unsigned int
#define __ELF__ 1
#define __GNUC_PATCHLEVEL__ 1
#define __linux 1
#define __unix 1
#define __linux__ 1
#define __USER_LABEL_PREFIX__
#define linux 1
#define __STDC_HOSTED__ 1
#define __WCHAR_TYPE__ long int
#define __gnu_linux__ 1
#define __WINT_TYPE__ unsigned int
#define __GNUC__ 3
#define __GXX_ABI_VERSION 102
#define i386 1
#define __GNUC_MINOR__ 2
#define __STDC__ 1
#define __PTRDIFF_TYPE__ int
#define __tune_i386__ 1
#define __REGISTER_PREFIX__
#define __NO_INLINE__ 1
#define __i386 1
#define __VERSION__ "3.2.1"
So it seems You have forgotten trailing '__'
Andris
- Raw text -