This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Proposal
On Thu, Sep 27, 2001 at 05:17:40AM -0300, Alexandre Oliva wrote:
> On Sep 17, 2001, Frank Klemm <pfk@fuchs.offl.uni-jena.de> wrote:
>
> > For instance try to convert
>
> > #define MILLION MY_MERGE_5 ( 1, _, 000, _, 000 )
>
> If you're going down this road, I'd rather just do
>
> #define MILLION MERGE3(1, 000, 000)
>
> where
>
> #define MERGE3(a,b,c) a##b##c
>
Everyone misinterprets this example.
This is not an example to write 'grouped' numbers.
It is an example what must be forbidden to be able to write a filter program
which removes '_' from numbers.
'_' should be allowed in numbers. It is allowed between the digits of
numbers in a C/C++ source _before_ preprocessing. It is not allowed between
digits which are 'created' during the preprocessor phase.
It is nearly impossible to write a filter which recognizes such '_'
and removes it. This is the reason for this rule. If gcc introduces a '_' in
numbers, such a filter is a MUST.
Exercise:
Write a program which translates the following C_99 program to C99:
------------------------------------------------------------------------
#include <stdio.h>
#define MY_MERGE_5(a,b,c,d,e) a##b##c##d##e
#define MILLION MY_MERGE_5 ( 1, _, 000, _, 000 )
#define BILLION MY_MERGE_5 ( MILLION, _, 000, _, 000 ) // UK notation
#define VAR MY_MERGE_5 ( a, _, b, _, c )
#define VAR2 MY_MERGE_5 ( a, b, c, d, e )
int
main ( void )
{
int abc = MILLION;
int VAR = MILLION;
long long x = BILLION;
int VAR2 = MILLION;
printf ("%d %d %lld %d %d\n", abc, VAR, x, VAR2, abcde );
printf ("1000000 1000000 1000000000000 1000000 1000000\n" );
return 0;
}
-----------------------------------------------------------------------
--
Frank Klemm