User forums > Using Code::Blocks
-D switch is expanded incorrectly
(1/1)
AlexF:
In CodeBlocks C++ project, settings, compiler, #define, I added these options:
--- Code: ---_DEBUG
DATA_DIR=\"/media/Shared/SiX/Data\"
--- End code ---
This produces the following command line:
--- Code: ---g++ -Wall -g -fPIC -save-temps -D_DEBUG -DDATA_DIR=\"/media/Shared/SiX/Data\" -I../Includes -c /media/Shared/SiX/SiXConfiguration/PathManager.cpp -o obj/Debug/PathManager.o
--- End code ---
When I open precompiler output, I see that source code line with DATA_DIR constant is expanded incorrectly. Source line:
--- Code: ---commonDataDir = DATA_DIR;
--- End code ---
is expanded as:
--- Code: ---commonDataDir = /media/Shared/SiX/Data;
--- End code ---
Should be:
--- Code: ---commonDataDir = "/media/Shared/SiX/Data";
--- End code ---
The same settings in the Eclipse CDT produce correct result. How can I fix this?
oBFusCATed:
See what is the real command executed by Eclipse's CDT, then you'll know what to enter in the defines field.
I would try to replace \" with ".
Also reading the gcc docs about this expansion will help you a lot.
By the way this is not a C::B problem, but a configuration problem...
AlexF:
Thanks. Eclipse CDT produces command line with the same parameter: -DDATA_DIR=\"/media/Shared/SiX/Data\". Anyway, I solved the problem by changing the source code, as was suggested in another forum:
http://stackoverflow.com/questions/3959398/d-option-is-expanded-incorrectly-from-g-command-line/3959495#3959495
Navigation
[0] Message Index
Go to full version