Macro Replacement in Strings

Paul Stachour stachour at sctc.com
Fri Apr 26 02:15:16 AEST 1991


In the c-compiler which we have been using, one embeds assembly code
with a sequence like:


  #pragma asm
     move.l #OS_CALL_OPEN,d0
     trap   #OS_TRAP
  #pragma endasm

In the one which we are now starting to use, the embed-form is like:

     asm("move.l #OS_CALL_OPEN,d0", 4);
     asm("trap   #OS_TRAP", 2);


Previously we have made defines such  as:

#define OS_TRAP 0
#define OS_CALL_OPEN 14

-----

Now, in our "old" compiler, we got the replacement we desired.
Now, in our "new" compiler, we do not get replacement.

I understand that this is the defined semantics of the CPP,
that one does not replace inside of strings, comments, 
or char-constants.

What I want is for CPP to create the form:


     asm("trap #0", 2);

so that the c-compiler can pass this on to the assembler.

I have tried various combinations of "#" and "##", but can't
seem to get it to work.  It is my understanding that if I
could get CPP to produce the form:

     asm("trap #" "0", 2);

that the strings would be concatenated together, but I don't
seem to be able to do that either.

Any suggestions from the net will be appreciated.

..Paul
-- 
Paul Stachour          SCTC, 1210 W. County Rd E, Suite 100           
stachour at sctc.com          Arden Hills, MN  55112
                             [1]-(612) 482-7467



More information about the Comp.lang.c mailing list