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

-D compiler argument with a value

I thought that the correct way to make a define with a value was to write:
MY_HEADDER=my_file.h, in the Define: textbox in "Options for Target", but its not working.
then I tried to use:
-DMY_HEADDER="my_file.h" in the "Misc Controls" textbox, but its not working also.

is it posible?

Parents Reply Children
  • Oh.. I should have wrote:

    -DMY_HEADDER="\"my_file.h\""

    in the "Misc Controls" box
    sorry for the truble..
    Best regards
    Jesper

  • -DMY_HEADDER="\"my_file.h\""

    The lesson to be learned from this is that #defining include file names, not only, but especially from outside the source file, is an option that's more trouble than it's worth.

    Passing "quotes" into tools via command lines is always tricky. Different tools, different environments, even just different versions or operation states of the same environment --- anything can break it. Facing that dragon just to obfuscate an #include statement is just not a good investment of your time.

  • I would agree with Hans-Bernhard.

    A better approach might be:

    #if defined OPTION_A
    #include "header_a.h"
    #elif defined OPTION_B
    #include "header_b.h"
    #else
    #error Must define an Option!
    #endif
    


    Note the final #error clause to prevent "undefined" operation if no option (or no recognised option) is specified...