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

Macro will be "optimized" by Keil C ?

If one macro is defined for "assignment":
Ex. #define equal(a,b) {a=b; }

And write: equal(A,1); equal(A,2); equal(A,3);

where A is pointer to XDATA space(mapped to H/W)

Keil C will "optimize" them and final result is A=3 ? or Keil C won't do this and expand them one by one ?

Thanks in advance...

Parents
  • As Nevill says, the macros are expanded by the preprocessor, and the compiler "sees" only the result of the expansion.

    Therefore whether the code originated from a macro expansion, or was typed verbatim, makes absolutely no differences whatsoever to the compiler.

    This, in turn, means that the use of a macro (or not) makes absolutely no differences whatsoever to the optimisation behaviour.

    This is all standard 'C' stuff - nothing specifically to do with Keil or the 8051.

    Incidentally, what would be the point of such a macro?

Reply
  • As Nevill says, the macros are expanded by the preprocessor, and the compiler "sees" only the result of the expansion.

    Therefore whether the code originated from a macro expansion, or was typed verbatim, makes absolutely no differences whatsoever to the compiler.

    This, in turn, means that the use of a macro (or not) makes absolutely no differences whatsoever to the optimisation behaviour.

    This is all standard 'C' stuff - nothing specifically to do with Keil or the 8051.

    Incidentally, what would be the point of such a macro?

Children