delorie.com is funded by banner ads.
  www.delorie.com/djgpp/v2faq/faq180.html   search  

| Previous | Next | Up | Top |

22.9 GCC says "garbage at end of number"

Q: There is a severe bug in GCC: it says "garbage at end of number" for this line:

      i = 0xfe+0x20;

Ain't it silly that such a great compiler would fail so miserably?


A: That's not a bug, that's a feature of the ANSI C language definition. By ANSI rules, the above expression is a single preprocessing token, unless you place whitespace in front of the plus sign. The reason for this seemingly counterintuitive feature is the syntax of floating-point constants in which letters `e' and `E' followed immediately by a sign signal a decimal exponent. You can use the -traditional compiler switch to turn this feature off (however, it will also turn off a plethora of other ANSI features; see the GCC docs for details).

Judging by the published draft, this is unchanged even in the forthcoming C9X standard.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright ⌐ 1998   by Eli Zaretskii     Updated Nov 1998  

Powered by Apache!

You can help support this site by visiting the advertisers that sponsor it! (only once each, though)