From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kevin Handy To: Frank Klemm Cc: Neil Booth , gcc@gcc.gnu.org Subject: Re: Proposal Date: Tue, 18 Sep 2001 11:37:00 -0000 Message-id: <3BA7937E.C96C9F42@srv.net> References: <200109151841.UAA04064@fuchs.offl.uni-jena.de> <20010917235928.A11347@daikokuya.demon.co.uk> <20010918021527.A14623@fuchs.offl.uni-jena.de> X-SW-Source: 2001-09/msg00721.html Frank Klemm wrote: > > On Mon, Sep 17, 2001 at 11:59:28PM +0100, Neil Booth wrote: > > > > > It is not allowed to compose numbers with '_' inside of macros. > > > > > > #define MILLION _MERGE5 ( 1, _, 000, _, 000 ) > > > [snip] > For instance you have a program which uses _ in numbers. > But not all compilers will will support this in the beginning. > > It should be possible to write a program which removes these _ inside of > numbers to allow to compile such source files with other compilers. > > Without this rule it is impossible to write such a program without > preprocessing the source file. And preprocessed files are no source files > anymore. > > 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 ) If you are using the underscore to make numbers more readable, then using a macro like this doesn't seem to me to be a step in the right direction. This looks (to me) to be harder to understand than a simple '1000000' would be. Another option for this that I'd prefer would be to write #define MY_MERGE_3(a,b,c) (a*1000000 + b*1000 + c) #define MILLION MY_MERGE_3(1,000,000) which doesn't need the extension, and you get to use comma's as the separator which is what people normally expect. This example is somewhat stupid, in that the million (1000000) constant is also the MY_MERGE_3 definition, but you still get the idea. > to the old representation. Note that MY_MERGE_5 is a self defined macro. Someone could write a "preprocessor" in C (which you should have a compiler for since you are trying to compile C code) that would filter out the underscores in numbers. Then you could distribute it along with your code for those running the wrong C compiler. Not the greatest solution, but I'd think it would be better to either use the extension or not.