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

Using 'C' pre-processor with A51

Common C51 & A51 headers are very useful. However, there seems to be no way to write code that is conditional upon command line defines that works for both the compiler and the assembler. For example, if I define the symbol _DEBUG on the command line, I can write -

$if _DEBUG
  Size set 100
  ; ...
$else
  Size set 50
  ; ...
$endif

for A51, or -

#ifdef _DEBUG
  #define size 100
  // ...
#else
  #define size 50
  // ...
#endif

for C51.

However, it appears that there are two separate symbol tables, so it is not possible to use just the 'C' preprocessor macros. Neither is it possible to translate between them. The following results in _DEBUG always being defined to the 'C' preprocessor -

#ifdef __A51__
  $if _DEBUG
    #define _DEBUG
  $endif
#endif

#ifdef _DEBUG
  // ...
#endif

Presumably this is because the 'C' preprocessor makes the first pass, ignoring any A51 code.

This somewhat limits the usefullness of common headers. Does anybody know of any workarounds, other than pre-translating the code?