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 get environment variables as #defines

I'd like to import an environment variable into the build. In other IDEs I've been able to do it as a command-line parameter - e.g.: -D FROM_ENV=$(ENV_VARIABLE) or something like that.

The idea is to have an environment variable set ENV_VARIABLE=1234
Then in the code I could write: int i = FROM_ENV;

So far I can't find a way to do it in uVision. I've tried a few combinations in the menu
PROJECT->OPTIONS FOR TARGET... dialog, on the C++ tab. There's a field of "Preprocessor symbols" and a "Misc Controls" field where it looks like I could maybe put command-line flags. But my experiments there aren't working.

Is this feature supported?

Parents
  • Hi Peter,

    the compiler takes the contents of a specific environment variable. Sadly the name changes with compiler versions. Example: ARMCC5_CCOPT

    I used this in past as
    ARMCC41_CCOPT -DSOMEVAR defines SOMEVAR
    ARMCC41_CCOPT -DULINK="2" defines ULINK having the value 2

    To find out how the name is for your compiler see doc or search exe for "CCOPT".

    Just to be complete, the assembler takes an environment variable like ARMCC41_ASMOPT,
    but syntax differs.

    hope that helps

    Martin

Reply
  • Hi Peter,

    the compiler takes the contents of a specific environment variable. Sadly the name changes with compiler versions. Example: ARMCC5_CCOPT

    I used this in past as
    ARMCC41_CCOPT -DSOMEVAR defines SOMEVAR
    ARMCC41_CCOPT -DULINK="2" defines ULINK having the value 2

    To find out how the name is for your compiler see doc or search exe for "CCOPT".

    Just to be complete, the assembler takes an environment variable like ARMCC41_ASMOPT,
    but syntax differs.

    hope that helps

    Martin

Children
No data