This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Macro expansion works differently on ASM and C files.

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.

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.    

1) Is this expected behavior?  (I don't think so).
2) If not, any pointers on where to look in the source to fix this?

If someone who is familiar with this part of the pre-processor wants to step
up and hit a home run (or tell me why this is correct behavior) that would be
great, too.


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