[SOLVED] Found these Macros in PIC32 Bootloader Code, please explain?

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
embeddedlaboratory.blogspot.in
Activity points
10,591
This is a header file i found, when i am reading the PIC32 Bootloader Code:-


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef __UART_H__
#define __UART_H__
 
#define DEFAULT_BAUDRATE            115200
 
#define Ux(y)         U2##y
 
#define UxBRG           Ux(BRG)
#define UxMODE          Ux(MODE)
#define UxSTA           Ux(STA)
#define UxSTAbits       Ux(STAbits)
#define UxSTACLR        Ux(STACLR)
#define UxSTASET        Ux(STASET)
#define UxTXREG         Ux(TXREG)
#define UxRXREG         Ux(RXREG)
 
#define TRANS_LAYER_Init UartInit
#define TRANS_LAYER_Task UartTask
#define TRANS_LAYER_Close UartClose
 
extern void TRANS_LAYER_Init(UINT);
extern void TRANS_LAYER_Task(void);
extern void UartClose(void);
#endif



I am not able to get what this macro do:-
#define Ux U2##y

What i assume is that the line
#define UxBRG Ux(BRG)
and UxBRG is equilavent to U2BRG

What is this ##?
 

hai,
Your assumption is correct.

Here, UxBRG is equivalent to U2BRG.

## is the token pasting or token concatenation operator. When the macro is expanded, the tokens on the sides of the operator combines together to form a single token

Regards
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…