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?
I'm writing this:
-DMY_HEADDER="my_file.h"
in the "Misc Controls" box and
#include MY_HEADDER
in the source file.
The error I get is this:
: error: #13: expected a file name
but if I write
#define MY_HEADDER my_file.h
I dont get any error.
Oh.. I should have wrote:
-DMY_HEADDER="\"my_file.h\""
in the "Misc Controls" box sorry for the truble.. Best regards Jesper
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...