Author Topic: Are value defines possible in the build-options ?  (Read 3571 times)

Offline eckard_klotz

  • Almost regular
  • **
  • Posts: 198
Are value defines possible in the build-options ?
« on: September 19, 2012, 03:57:28 pm »
Hello Everybody.

I tried to define in the build-options in the dialogue Project >> Build options  >> Compiler-settings >> #defines (individual target setting) a preprocessor-variable with a value like here:

Quote
RELEASE 0
(trial to define the preprocessor-constant RELEASE with the value 0)

After starting the build-process (gnu-compiler) I've got the following error in the Build messages
Quote
File|Line|message                  |
 0   |    |No such file or directory|



In the Build log I found:
Quote
mingw32-g++.exe -Wall -fexceptions
                -D__dsPIC30F4011__
       -DSEND_HELLO_WORLD
       -DUNITTEST
       -DSHOW_FILE_OF_USE 
                -O2 
                -DRELEASE 0    
       -I..\..\..\..\.. (more include-pathes)
       -c D:\... sorcepath ...\c\tst_pwm_oc.cpp
       -o obj\Release_0\13_Tests_\UnitTest\TL\tst\c\tst_pwm_oc.o
       
mingw32-g++.exe: 0: No such file or directory

I assume that mingw (the compiler) is not able to understand that the character-sequence 0 should be the content of the preprocessor-constant RELEASE. Is this right? If yes, is there a possibility to change the configuration in the dialog so that the compiler gets an valid value-definition? Currently I use as a workaround a RELEASE_0 (without a value) in the compiler-settings of the project together with an external header-file with a compiler-switch like this:

Quote
#if   defined(RELEASE_0)
  #define RELEASE 0
 #elif defined(RELEASE_1)
  #define RELEASE  1
 #elif defined(RELEASE_2)
  #define RELEASE  2
 #else

 #endif

What is the way recommended by the C::B team?




Best regards,
              Eckard Klotz.

PS.: I use the lates nigthly 8248 on windows xp sp3 together with mingw 4

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7607
    • My Best Post
Re: Are value defines possible in the build-options ?
« Reply #1 on: September 19, 2012, 04:13:28 pm »
Try this, IIRC it works.

Code
RELEASE=1
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline eckard_klotz

  • Almost regular
  • **
  • Posts: 198
Re: Are value defines possible in the build-options ?
« Reply #2 on: September 20, 2012, 10:12:09 am »
Hello Stahta1.

Thanks for your fast response!

I tried it out and it works for mingw also. But it is very essential to use no whitespaces like this
Code
RELEASE = 1
That was my first try before I posted my questuion. By using spaces inside the definition the = and the 1 are not interpreted as part of the #define but as file-name.

Now if I think about, this makes sence. If the definition will only be copied into the argument-string of the called binary (the compiler) windos is using the white-space as splitt-character, what means the = and the 1 will be interpreted as independent arguments.

Pehaps it may be helpfull to add small hint or tool-tip into the configuration-dialogue that shows how to do it and how not. Alternativly this posted example may be used as part of a trouble-shooting list.

Thanks for your help,
                             Eckard Klotz.