Understanding the core lib


(Boti Kis) #1

So i’m practicing and doing stuff and i’ve stumbled across this in the core.h:

// bit values for button states
#define LEFT_BUTTON _BV(5)
#define RIGHT_BUTTON _BV(6)
#define UP_BUTTON _BV(7)
#define DOWN_BUTTON _BV(4)
#define A_BUTTON _BV(3)
#define B_BUTTON _BV(2)

And sightly below it:

// bit values for button states
#define LEFT_BUTTON _BV(5)
#define RIGHT_BUTTON _BV(2)
#define UP_BUTTON _BV(4)
#define DOWN_BUTTON _BV(6)
#define A_BUTTON _BV(1)
#define B_BUTTON _BV(0)

I’m not a c/++ pro, only did high level stuff and lot obj-c but i feel slightly uncomfortable with this.
Does this have a deeper meaning? As far as i understand the preprocessor, the second definition overrides the first one - am i right?


(Boti Kis) #2

Ahhh i’ve missed the

#elif defined(AB_DEVKIT)

can be closed/deleted. i’m stupid.


(Ross) #3

Ah don’t be so hard on yourself!

If you had the question, I’m sure others will as well. It’s actually not a bad idea to close out your own question with an answer to what you were curious about.

And yep, those are all pre-processor directives that will be ran and set by the compiler before the source for the program itself is compiled.