Target deprecation, round three

Chris Lattner sabre@nondot.org
Tue Feb 25 16:57:00 GMT 2003


Fergus Henderson wrote:
>On 24-Feb-2003, Zack Weinberg <zack at codesourcery dot com> wrote:
>> There are four possible ways to get around this problem:
>> - Replace all these character constants with integer or enumeration
>>   constants.  I consider this infeasible, it would make these parts of
>>   the compiler much harder to maintain.

>Well, sure, don't use integer constants directly, use #defines!
>I don't see why e.g.
>	if (c == SLASH_CHAR)
>is so much harder to maintain than
>	if (c == '/')

Or better yet, how about:

if (c == CHAR_LITERAL('/')) ...

Where on an ascii machine, the CHAR_LITERAL (or whatever) #define just
returns its argument.  On an EBCDIC machine it could index into a 256
element char array to do the mapping.  A bit slower on EBCDIC machines,
but no impact on ASCII machines.

If new code forgets to use the CHAR_LITERAL macro, it would just break on
EBCDIC machines, without affecting the correctness of the ASCII machines.
IMHO, this is better than using a slew of #defines for each character, and
having to remember what each char maps to...

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/



More information about the Gcc mailing list