Date: Tue, 16 May 95 01:43:35 PDT Reply-To: pdasilva AT tpone DOT telepac DOT pt (P. da Silva) From: pdasilva AT tpone DOT telepac DOT pt (P. da Silva) To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: garbage at end of number [Was BUG or What?] Thanks for all kind answers to my post "BUG OR WHAT". Here is it and a summary of all responses I received: > FILE TP.H > #define CT 0x2000 > #define AA (0xfd+CT) > #define BB (0xfe+CT) > #define CC (0xff+CT) > > FILE TP.C > #include "tp.h" > static int x[]={BB}; > > Compiling this with GCC ver. 2.6.3 gives the error message > tp.c:2: garbage at end of number > > But if you change to > static int x[]={AA}; > or > static int x[]={CC}; > > it compiles OK. > The C language requires to have whitespace between a hex-number ending in "e" and a subsequent "+" or "-". There's a VERY good reason for this apparently bizarre rule. Floating Point Constants. E.g. float a = 12e4; float b = 13e-2; /* peculiar but legal usage: */ float c = 0x10e+3; /* which is NOT the same as: */ float d = 0x10e + 3; Some GCC INFO follows: ====================== In the info-node `Incompatibilities', it says: * GNU C complains about program fragments such as `0x74ae-0x4000' which appear to be two hexadecimal constants separated by the minus operator. Actually, this string is a single "preprocessing token". Each such token must correspond to one token in C. Since this does not, GNU C prints an error message. Although it may appear obvious that what is meant is an operator and two values, the ANSI C standard specifically requires that this be treated as erroneous. A "preprocessing token" is a "preprocessing number" if it begins with a digit and is followed by letters, underscores, digits, periods and `e+', `e-', `E+', or `E-' character sequences. To make the above program fragment valid, place whitespace in front of the minus sign. This whitespace will end the preprocessing number. .. If you pass Option `-ftraditional' to gcc, this, among other things, happens: * Certain constructs which ANSI regards as a single invalid preprocessing number, such as `0xe-0xd', are treated as expressions instead. Thanks again Paulo