News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

-D switch is expanded incorrectly

Started by AlexF, October 18, 2010, 03:10:30 PM

Previous topic - Next topic

AlexF

In CodeBlocks C++ project, settings, compiler, #define, I added these options:

_DEBUG
DATA_DIR=\"/media/Shared/SiX/Data\"

This produces the following command line:

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:

commonDataDir = DATA_DIR;

is expanded as:

commonDataDir = /media/Shared/SiX/Data;

Should be:

commonDataDir = "/media/Shared/SiX/Data";

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...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

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