whats the difference between if/else and #if/#else

Share you PDE file with our community
Post Reply
Smotz
Posts: 412
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

whats the difference between if/else and #if/#else

Post by Smotz »

More of a general programming question, but:

whats the difference between if/else and #if/#else ?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: whats the difference between if/else and #if/#else

Post by lnevo »

Its really #ifdef and #endif

These are pre-processing declarations that are used by the compiler vs actual c/c++ code that gets compiled.

So. #define x y
Replaces all occurance of x with y

Whereas

int x=y; is in code and uses a variable which takes up memory, the #define gets replaced before the compiler and so isnt a variable.

Essentially a lot of the #ifdef you see is aimed at making the ino smaller by only including code that is used.

Not sure how much that helps but maybe gets you started :)
Smotz
Posts: 412
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: whats the difference between if/else and #if/#else

Post by Smotz »

lol, thx. I was curious.
Post Reply