我正在查看一些微控制器的C头文件,其中有如下代码:
#define OSCCONL OSCCONL
extern volatile uint8_t OSCCONL __attribute__((__sfr__));
#define OSCCONH OSCCONH
extern volatile uint8_t OSCCONH __attribute__((__sfr__));
#define CLKDIV CLKDIV
extern volatile uint16_t CLKDIV __attribute__((__sfr__));
__extension__ typedef struct tagCLKDIVBITS {...}
那些重复的"#define A A"有什么作用?
#define OSCCONL
,那么它不会起到同样的作用吗?问题是为什么OSCCONL
出现了两次。 - edtheprogrammerguyOSCCONL
定义它并给出定义值OSCCONL
可能是一种方便的做法,因为如果需要更改定义而不更改定义,则更改定义值OSCCONL
将更容易。 - Raildex#define OSCCONL OSCCONL
将替换变量声明extern volatile uint8_t OSCCONL __attribute__((__sfr__))
中的OSCCONL
为OSCCONL
。提出的替代方案#define OSCCONL
将用空字符串替换OSCCONL
,导致语法错误extern volatile uint8_t __attribute__((__sfr__))
。 - Bodo