Bug 29546

Summary: Wrong preprocessing when value of a define is "powerpc"
Product: gcc Reporter: Guillaume Libersat <glibersat>
Component: preprocessorAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED INVALID    
Severity: normal CC: gcc-bugs
Priority: P3    
Version: 4.1.2   
Target Milestone: ---   
Host: powerpc-linux-gnu Target: powerpc-linux-gnu
Build: powerpc-linux-gnu Known to work:
Known to fail: Last reconfirmed:

Description Guillaume Libersat 2006-10-22 12:59:50 UTC
When you want to set the "powerpc" string as a value of a define (-D or #define), you get the integer value 1 instead of the string.

Here's an example :

test.c :
-----
Arch = ARCH
-----

With the "powerpc" string (bug) :
gcc -E -DARCH=powerpc test.c

Result is :
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.c"
Arch = 1

With another string (no bug) :
gcc -E -DARCH=ia32 test.c

Result is :
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.c"
Arch = ia32


== GCC Config ==
Using built-in specs.
Target: powerpc-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --disable-softfloat --enable-targets=powerpc-linux,powerpc64-linux --with-cpu=default32 --enable-checking=release powerpc-linux-gnu
Thread model: posix
gcc version 4.1.2 20061007 (prerelease) (Debian 4.1.1-16)
Comment 1 Richard Biener 2006-10-22 13:21:23 UTC
powerpc is one of the standard defines gcc defines if running on ppc-linux.  It is changed to __powerpc if you define powerpc yourself.
Comment 2 Andrew Pinski 2006-10-22 14:15:55 UTC
Note if you add -pedantic or -ansi or -std=c99 or -std=c89, powerpc will not be defined as it is not in the reserved space.