# Contiki os preprocessor defines

I was looking at contiki how it defines port direction for telob/sky: https://github.com/contiki-os/contiki/blob/master/cpu/msp430/dev/hwconf.h and am buffled.

I mean, in plain msp430 jurgon you could do this

P1DIR = 0x01;


to set up, for example, port 1 or

P1SEL &= (~BIT0);    // Set P1.0 SEL for GPIO


Now, the contiki master programmer has something like:

#define HWCONF_PIN(name, port, bit) \
static CC_INLINE void name##_SELECT() {P##port##SEL &= ~(1 << bit);}


and so on..

to make programming the port easier but I can't figure out how this enternally gets executed.

For example, how is this " name##_SELECT()" called?

I know it's a newbie question but bear with me. Thanx

• What's telob/sky? – m.Alin Jul 21 '14 at 13:30
• google.gr/… – Nick_K Jul 21 '14 at 13:41
• This isn't an electronics question, it's a C programming question. Specifically, the ## operator is how you concatentate the values of symbols in the C preprocessor. Once you understand that, you should be able to work out what the macro actually does. – Dave Tweed Jul 21 '14 at 13:53
• @DaveTweed Thanx for the hint. I was stuck at figuring out how's concatenation is defined in C preprocessor. Now, I can find out how this macro works. – Nick_K Jul 22 '14 at 7:27