Author Topic: -D switch is expanded incorrectly  (Read 3447 times)

Offline AlexF

  • Single posting newcomer
  • *
  • Posts: 6
-D switch is expanded incorrectly
« 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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: -D switch is expanded incorrectly
« Reply #1 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...
(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!]

Offline AlexF

  • Single posting newcomer
  • *
  • Posts: 6
Re: -D switch is expanded incorrectly
« Reply #2 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