This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to conditionally NOAREG a fn?

Hi All.

Imagine a function that looks like this:

DEFINED_SYMBOL1
type FnName(args) DEFINED_SYMBOL2
{
 ...;
}
By appropriate definition of DEFINED_SYMBOL1 and DEFINED_SYMBOL2, I would like to end up with:
type FnName(args)
{
 ...;
}
or
#pragma NOAREGS
type FnName(args) reentrant
{
 ...;
}
The DEFINED_SYMBOL2 part is really easy, either
#define DEFINED_SYMBOL2
or
>#define DEFINED_SYMBOL2 reentrant
But the DEFINED_SYMBOL1 isn't so easy, because C51 won't allow me to
#define DEFINED_SYMBOL1 #pragma NOAREGS
("misused # operator"). So how should I proceed?

BTW, the source file has multiple functuons in it, so compiling with NAREGS on the command line is not an option.

Thanks,

Parents
  • One C rule you must obey is that you can't have a pre-proc. directive in a pre-proc. directive. E.g.

    #define ILLEGAL  #pragma 
    won't work.

    There is an exception for token pasting and concatenation, e.g.
    #define STRINGER(x)    #x
    #define STRING_CAT(x, y) STRINGER(x) ## STRINGER(y)
    Which can be fun.

Reply
  • One C rule you must obey is that you can't have a pre-proc. directive in a pre-proc. directive. E.g.

    #define ILLEGAL  #pragma 
    won't work.

    There is an exception for token pasting and concatenation, e.g.
    #define STRINGER(x)    #x
    #define STRING_CAT(x, y) STRINGER(x) ## STRINGER(y)
    Which can be fun.

Children
No data