Proposal
Neil Booth
neil@daikokuya.demon.co.uk
Tue Sep 18 11:06:00 GMT 2001
Frank Klemm wrote:-
> For instance you have a program which uses _ in numbers.
> But not all compilers will will support this in the beginning.
Sure.
> It should be possible to write a program which removes these _ inside of
> numbers to allow to compile such source files with other compilers.
If the _'s aren't already in your source code, I don't see much point
putting them there with macros. Wasn't the whole idea legibility?
> Without this rule it is impossible to write such a program without
> preprocessing the source file. And preprocessed files are no source files
> anymore.
Well, you might be able to filter it through sed or something, with a
little difficulty.
> To prevent this it is forbidden to use this feature in conjunction with
> token concatenation. At least as long as this is not an ISO standard.
>
> For instance try to convert
>
> #define MILLION MY_MERGE_5 ( 1, _, 000, _, 000 )
>
> to the old representation. Note that MY_MERGE_5 is a self defined macro.
I don't know what you mean by a self-defined macro. I don't
understand why you're using macros (see comment above). I'm not even
sure what the definition of MY_MERGE_5 is, though I might guess.
Anyway, if you insist on macros, you could get what you want through
an extra indirection, and an extra macro
#if COMPILER_UNDERSTANDS_EXTENDED_NUMBERS
#define UNDERSCORE _
#else
#define UNDERSCORE
#endif
#define MY_MERGE_5_INDIRECT (a, b, c, d, e) MY_MERGE_5 (a, b, c, d, e)
#define MILLION MY_MERGE_5_INDIRECT (1, UNDERSCORE, 000, UNDERSCORE, 000)
But I really can't see the point here.
Neil.
More information about the Gcc
mailing list