pointers in C with a #define

Posted by milan on Stack Overflow See other posts from Stack Overflow or by milan
Published on 2010-12-26T17:52:48Z Indexed on 2010/12/26 17:53 UTC
Read the original article Hit count: 171

Filed under:
|
|
|

The function:

#define ASSOC(port) (*(volatile bit_field *) (&port))

The function call:

#define SCLK ASSOC(PORTC).bit0

bit_field defined as a struct like this:

typedef struct {
 unsigned char bit0 :1, bit1 :1, bit2 :1, bit3 :1, bit4 :1, bit5 :1,
   bit6 :1, bit7 :1;
} bit_field;

I don't know where &port is defined.

Can someone please explain how the function is read and how it works please? I am not very good with pointers and this example in particular is very confusing with "*" in the front and at the end and the "&" with the port.

Thank you

© Stack Overflow or respective owner

Related posts about c

    Related posts about microcontroller