Hi there !
I'm using Code::Blocks since few years and I like it ! But there is an option that I cannot use, and I don't know what is wrong in my use... #defines.
Look : I create a target named "debug", with DEBUG 1 in the #defines tab. Then, I write :
int main()
{
#ifdef DEBUG
cout << "debug" << endl;
#endif
/* ... */
return 0;
}
It should show "debug" in the console, but it doesn't... What's wrong ?
Thank you !
PS : I'm using GNU GCC compiler...
A lot of reads, but no answer.... Is it so complicated ? :P
It looks like it should work to me.
I would try using a define other than DEBUG; the standard is NDEBUG to say not debug.
and then to test for #ifndef NDEBUG
I am a C::B newbie, so there could be something C::B related that I don't understand.
Tim S
I tried this :
#ifndef ZAFDSGERGEG
cout << "debug" << endl;
#endif
with ZAFDSGERGEG defined....
And it showed "debug" : it shouldn't :x
I really don't understand :?
Where are you defining it?
The standard location in CB is
Project -> Build Option
Compiler Tab; #defines Tab
In the defines tab you have to put DEBUG=1. Notice no spaces and the equality sign.
Edit: Anyway, I tried and it should also work with only having "DEBUG" in the defiens tab.
Did you...
- put the define in a wrong target (e..g in the release target but compiled the debug target?!)
- forget to re-compile after you had changed the define?
- do you set DEBUG=0 somewhere in the code that gets included?
With regards, Morten.
Quote from: xurei on October 08, 2006, 01:57:44 PM
I tried this :
#ifndef ZAFDSGERGEG
cout << "debug" << endl;
#endif
with ZAFDSGERGEG defined....
And it showed "debug" : it shouldn't :x
Works very well for me. Did you forget to re-compile?
With regards, Morten.
Okay, here's my real code :
/* debug.h */
#ifdef ZAFDSGERGEG
#include <iostream>
using namespace std;
#define echo(text) cout << text
#else
#define echo(text)
#endifThis code is helpful to show somemore informations when I'm debugging my sources...
And for your questions :
QuoteDid you...
- put the define in a wrong target (e..g in the release target but compiled the debug target?!) NO
- forget to re-compile after you had changed the define? NO (maybe yes actually, but I just recompile completely and the problem is still present...)
- set DEBUG=0 somewhere in the code that gets included? NO
It is not the first time I tried to use the defines, but it never worked...
Ok, I reinstalled C::B, and now it works...
Thank you for the help !
xurei