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

Defining C Preprocessor Constants in A51

Does anyone know a way to define C preprocessor comments at the command line for A51? For example, in C I would do something like:

C51 foo.c DEFINE(SOME_CONST)

but the "DEFINE" directive does not work in A51. In addition, the C preprocessor in A51 does not recognize constants declared with the "SET" directive as C defined constants. In other words, if I do:

A51 foo.a51 SET(SOME_CONST=1)

and then I have the following line in my assembly file:

#ifdef SOME_CONST

the expression will be interpreted as being false.

Thanks!

Parents
  • Does anyone know a way to define C preprocessor comments at the command line for A51? For example, in C I would do something like:<br>
    <br>
    C51 foo.c DEFINE(SOME_CONST)<br>
    <br>
    but the "DEFINE" directive does not work in A51. In addition, the C preprocessor in A51 does not recognize constants declared with the "SET" directive as C defined constants. In other words, if I do:<br>
    <br>
    A51 foo.a51 SET(SOME_CONST=1)<br>
    <br>
    and then I have the following line in my assembly file:<br>
    <br>
    #ifdef SOME_CONST<br>
    <br>
    the expression will be interpreted as being false.<br>
    <br>
    Thanks!

Reply
  • Does anyone know a way to define C preprocessor comments at the command line for A51? For example, in C I would do something like:<br>
    <br>
    C51 foo.c DEFINE(SOME_CONST)<br>
    <br>
    but the "DEFINE" directive does not work in A51. In addition, the C preprocessor in A51 does not recognize constants declared with the "SET" directive as C defined constants. In other words, if I do:<br>
    <br>
    A51 foo.a51 SET(SOME_CONST=1)<br>
    <br>
    and then I have the following line in my assembly file:<br>
    <br>
    #ifdef SOME_CONST<br>
    <br>
    the expression will be interpreted as being false.<br>
    <br>
    Thanks!

Children
  • I can't get it to work either, but I found a couple workarounds that may help:

    A51 foo.a51 SET(SOME_CONST=1)

    $IF (SOME_CONST = 1)
    SOME_CONST SET 1
    ;;...more code
    $ELSE
    SOME_CONST SET 0
    ;;...more code
    $ENDIF

    The $IF tests use the command-line SET variables, so you might just use them instead of #ifdef. Also, if you want to use the variables in other assembler expressions, then the assembler "SET" statements get you a named variable you can use, e.g.:

    TABLE db SOME_CONST