Author Topic: String defines in C::B  (Read 5014 times)

Offline pasdVn

  • Multiple posting newcomer
  • *
  • Posts: 15
String defines in C::B
« on: August 27, 2011, 05:01:01 pm »
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.
 
« Last Edit: August 27, 2011, 05:03:36 pm by pasdVn »

Offline Freem

  • Almost regular
  • **
  • Posts: 219
Re: String defines in C::B
« Reply #1 on: August 27, 2011, 11:49:15 pm »
I'm not sure (and don't want to try, sorry), but what about surrounding by " the \"test\" ?

Offline pasdVn

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: String defines in C::B
« Reply #2 on: August 28, 2011, 12:26:12 am »
You mean like VERSION="\"test\""?

Just tried it: Same result :(

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: String defines in C::B
« Reply #3 on: August 28, 2011, 09:01:21 am »
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.

Offline pasdVn

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: String defines in C::B
« Reply #4 on: September 03, 2011, 04:10:07 pm »
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)

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...