This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Macro expansion works differently on ASM and C files.
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: gp at qnx dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 14 Aug 2003 21:22:09 +0100
- Subject: Re: Macro expansion works differently on ASM and C files.
- References: <200308141612.h7EGC9e05264@webmail.qnx.com>
gp@qnx.com wrote:-
> Hi. I have source with macros in it that use the "##" concatenation to
> construct assembly output. The macros are expanded differently based on
> whether the file has a ".c" extension vs a ".S", with identical content
> (actually a symlink to the same file foo.S --> foo.c).
>
> The simple test case is:
>
> #define FOO(a,b) b,$##a
> FOO (a, b)
> FOO ( a, b)
>
> As 'foo.c' both FOO macro calls are expanded to "b,$a". As 'foo.S' the second
> one is expanded to "b,$ a". As you can see, I have a simple workaround, but
> it does look like a bug to me.
No, asm is different in several respects. We don't permit dollars in
identifiers by default, for example, whereas we might with C files.
> The actual macro being used is:
>
> #define SAVE_ONE(reg,bias) mfc0 t0,$##reg; nop; sw t0,(reg*4)+bias(a0)
> ...
> SAVE_ONE ( 0, 0)
>
> This is a problem as the assembler chokes on "mfc0 t0,$ 0;" where "mfc0
> t0,$0;" is fine.
Try -fdollars-in-identifiers?
Neil.