This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

the new preprocessor is more strict...



Andrew asked me to forward this bit of information:

Geoffrey Keating wrote:
> 
> The sims contain, in a number of places, code which effectively does
> this:
> 
> #define N 1
> #define T2H_1(X) endian_t2h_1(X)
> #define CONCAT2(a,b)     a##b
> #define XCONCAT2(a,b)     CONCAT2(a,b)
> #define unsigned_N XCONCAT2(unsigned_,N)
> #define T2H_N XCONCAT2(T2H_,N)
> T2H_N(*(unsigned_N*)core_translate(mapping, addr));
> 
> ISO C99 requires that this expands to
> 
> endian_t2h_1(*(XCONCAT2(unsigned_,1)*)core_translate(mapping, addr));
> 
> because it says `if any nested replacements encounter the name of the
> macro being replaced, it is not replaced.'
> 
> I believe that in the former C89, this was implementation-defined.
> This changed in the past month in GCC to behave correctly.
>
> So I'll be submitting a patch.  The easiest way to fix this is to
> make T2H_1 and similar not take arguments, as this prevents the
> replacements from qualifying as 'nested'.

[I've already sent the patch in, but I forget if I included all the
explanation.]

-- 
- Geoffrey Keating <geoffk@geoffk.org>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]