Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: AlexF on October 18, 2010, 03:10:30 pm

Title: -D switch is expanded incorrectly
Post by: AlexF on October 18, 2010, 03:10:30 pm
In CodeBlocks C++ project, settings, compiler, #define, I added these options:
Code
_DEBUG
DATA_DIR=\"/media/Shared/SiX/Data\"
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
When I open precompiler output, I see that source code line with DATA_DIR constant is expanded incorrectly. Source line:
Code
commonDataDir = DATA_DIR;
is expanded as:
Code
commonDataDir = /media/Shared/SiX/Data;
Should be:
Code
commonDataDir = "/media/Shared/SiX/Data";
The same settings in the Eclipse CDT produce correct result. How can I fix this?
Title: Re: -D switch is expanded incorrectly
Post by: oBFusCATed on October 18, 2010, 03:32:20 pm
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...
Title: Re: -D switch is expanded incorrectly
Post by: AlexF on October 18, 2010, 04:22:48 pm
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