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
  • Macros are processed by the pre-processor - This is a simple text processor and does no optimizations.

    The (expanded) output of this text processing is passed on to the compiler, which may decide to optimize the sequence.

    If (as you are indicating) you do not want the sequence of access to XDATA to be optimized, then you should use the volatile attribute for the pointer to the location.

Reply
  • Macros are processed by the pre-processor - This is a simple text processor and does no optimizations.

    The (expanded) output of this text processing is passed on to the compiler, which may decide to optimize the sequence.

    If (as you are indicating) you do not want the sequence of access to XDATA to be optimized, then you should use the volatile attribute for the pointer to the location.

Children