View previous topic :: View next topic |
Author |
Message |
jeremy6996 Expert Cheater
Reputation: 0
Joined: 20 May 2007 Posts: 100
|
Posted: Sun Jul 08, 2007 6:32 pm Post subject: C++ Define help needed |
|
|
I get the whole code and I know what it does but I don't get this.
Code: | #define aa
#ifdef aa
//Do somthing
#else
//Do somthing
#endif |
The thing I don't get is. Why would it not be defined it it got through the debugger. And I put the define code up there. What is the "#ifdef" used for? I know its to see if it was defined or not, but why would it not be defined?
|
|
Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Sun Jul 08, 2007 6:35 pm Post subject: |
|
|
it wouldnt be defined if you
a) took out the line
b) #undef it
|
|
Back to top |
|
 |
jeremy6996 Expert Cheater
Reputation: 0
Joined: 20 May 2007 Posts: 100
|
Posted: Sun Jul 08, 2007 6:37 pm Post subject: |
|
|
appalsap wrote: | it wouldnt be defined if you
a) took out the line
b) #undef it |
=P I see. But that brings up another one of my questions, why do people bother to #undef things?
|
|
Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Sun Jul 08, 2007 6:40 pm Post subject: |
|
|
jeremy6996 wrote: | why do people do this? |
ok, say you were developing a shareware program, and have two editions, trial and full.
Code: |
#ifdef FULL
do_awesome_stuff();
#else
obnoxious_message("sorry this feature is only enabled in the full version");
#endif
|
now you only have to #define FULL if you want to build the application for your registered users instead of maintaining two seperate programs.
|
|
Back to top |
|
 |
jeremy6996 Expert Cheater
Reputation: 0
Joined: 20 May 2007 Posts: 100
|
Posted: Sun Jul 08, 2007 6:42 pm Post subject: |
|
|
Oh, I get it now thanks.
|
|
Back to top |
|
 |
benlue Moderator
Reputation: 0
Joined: 09 Oct 2006 Posts: 2142
|
Posted: Sun Jul 08, 2007 8:17 pm Post subject: |
|
|
Question answered, locked.
|
|
Back to top |
|
 |
|