Page 1 of 1

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

Posted: Tue Jul 16, 2013 1:09 pm
by Smotz
More of a general programming question, but:

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

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

Posted: Tue Jul 16, 2013 1:29 pm
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 :)

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

Posted: Wed Jul 17, 2013 1:43 pm
by Smotz
lol, thx. I was curious.