User forums > Using Code::Blocks
String defines in C::B
(1/1)
pasdVn:
Hey guys,
just a very short question, that I am not abled to solve on my own: I want to define a string (a character sequence) via "Project build Options"->"Compiler settings"->"#defines" in this way:
VERSION=\"test\"
The problem is, that C::B somehow seems to ignore the "" in some way, as i get the compiler error "error: ‘test’ was not declared in this scope" when trying to use this define in the code. The compiler log prints out the correct command:
g++ -Wall -DVERSION=\"test\" -g -Wextra -Wall -I/usr/include/freetype2 -c /home/tobias/Entwicklung/jaaa/src/jaaa.cc -o obj/Debug/src/jaaa.o
If I enter this line in a terminal it works as intended :(. Am I the problem or is it CB?
PS: I am using the current nightly build from jens' deb-repo on ubuntu 10.11 and 11.04.
Freem:
I'm not sure (and don't want to try, sorry), but what about surrounding by " the \"test\" ?
pasdVn:
You mean like VERSION="\"test\""?
Just tried it: Same result :(
Jenna:
Depends onwhat you want todo with the define, and if it should work reliable, probably also on other platforms.
Maybe this is what you need: http://forums.codeblocks.org/index.php/topic,10304.msg71118.html#msg71118, see also the link inside.
pasdVn:
Yes, in fact the same Problem. But in my case even VERSION=\\"test\\" does not work:(. CB gives me the following compiler log here:
--- Code: ---<command-line>:0:9: warning: missing terminating " character
Process terminated with status 1 (0 minutes, 1 seconds)
0 errors, 1 warnings (0 minutes, 1 seconds)
--- End code ---
Quite strange. No error, but return 1 and I don't get any executables out. What am I doing wrong (I only want to build this project at linux, btw)?
The real problem, that was also not answered in this other thread, as I think, is:
--- Quote ---I do not understand. On both platforms (Windows and Linux), gcc on the commandline needs -DDEF_NAME=\"DEF_VALUE\", i.e. using single backslash to escape the quotation mark.
The difference is that if I specify this in #defines in the 'Project build options', I have to use DEF_NAME=\"DEF_VALUE\" on Windows and DEF_NAME=\\"DEF_VALUE\\" on Linux. In other words, it seems to me that the difference comes from C::B, not from the compiler...
--- End quote ---
Navigation
[0] Message Index
Go to full version