Author Topic: %ifdef with macro-parameters  (Read 3598 times)

nobody

  • Guest
%ifdef with macro-parameters
« on: March 09, 2005, 09:45:57 AM »
Hi!


I have a questions about NASM preprocessing:
I want to write a marco like this

%macro ohh 2
  %ifdef %1_n%2
    do anything
  %endif
%endmacro

ohh crt,Proc

with should do something if crt_nProc is defined.
But NASM preprocessor quits with an error-message

'%ifdef' expects macro identifiers

How could I get this work?


Cheers!

nasm64developer

  • Guest
Re: %ifdef with macro-parameters
« Reply #1 on: March 09, 2005, 07:20:55 PM »
Ah yes, you want a means for preventing the
expansion of an smac that you are handing to
an mmac as an argument, so that the mmac is
going to see the smac identifier, instead of
the smac expansion.

See SF RFE #829879 -- in NASM64 I addressed
this need via %#.

nobody

  • Guest
Re: %ifdef with macro-parameters
« Reply #2 on: March 10, 2005, 02:18:54 PM »
Hi!


I got the nasm 0.98-version and tried to do the changes
you described in SF RFE #829879 but a wasn't able to get things work.
(I'm a pascal-ian and not too familiar neighter with C
nor with the nasm-code...)
Could you give me a hint what to do?

I used the free Borland C++ 5.5 compiler under Win98 and
managed to compile the nasm form the original 0.38-code.
Then I changed preproc.c. As you said in step 5 I added


skip = FALSE;
if (tline->type == TOK_SMAC_SKIP ){
t = tline;
tline = tline->next;
nasm_free(t->text);
nasm_free(t);
if (tline){
skip = TRUE;
} else {
break;
}
}


in the expand_smacro() just before


if (tline->type == TOK_SMAC_END) {
tline->mac->in_progress = FALSE;
t = tline;
tline = tline->next;
nasm_free (t);
} else {
...


But then I get the error-message

Misplaced break in function expand_smacro

Did I insert that at the wrong place?


Thanks a lot!

nasm64developer

  • Guest
Re: %ifdef with macro-parameters
« Reply #3 on: March 10, 2005, 02:44:30 PM »
> Did I insert that at the wrong place?

Here is how it looks in my pp_nasm.c. (The
TOK_SEP part is for SF RFE #839215.)

...
                continue;  /* main token loop */
              }
            }
        }

if ( tline->type == TOK_SMAC_SKIP ) {
  t = tline;
  tline = tline->next;
  nasm_free ( t->text );
  nasm_free ( t );
  if ( tline ) {
    skip = TRUE;
    if (
         ( tline->type == TOK_SMAC_SKIP ) ||
         ( tline->type == TOK_SEP )
    ) {
      continue;
    }
  } else {
    break;
  }
}

if (tline->type == TOK_SMAC_END) {
          ...