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

Share you PDE file with our community

Posts: 411
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA
PostPosted: Tue Jul 16, 2013 1:09 pm
More of a general programming question, but:

whats the difference between if/else and #if/#else ?
User avatar
Posts: 5343
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Tue Jul 16, 2013 1:29 pm
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 :)

Posts: 411
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA
PostPosted: Wed Jul 17, 2013 1:43 pm
lol, thx. I was curious.

Return to My PDE/INO file

Who is online

Users browsing this forum: No registered users and 1 guest

cron