关于宏定义问题
请教:在32位带操作:
#define GPIO_OUT *((unsigned int *)((0x40010C0C & 0xF0000000) + 0x02000000 + ((0x40010C0C & 0x00FFFFFF)<<5) + (5<<2))) = 0;
在主函数中调用GPIO_OUT 就可以
而定义
#define GPIO_OUT *((unsigned int *)((0x40010C0C & 0xF0000000) + 0x02000000 + ((0x40010C0C & 0x00FFFFFF)<<5) + (5<<2))) ;
在主函数中调用GPIO_OUT = 0; 就显示
..\User\main.c(19): warning:#174-D: expression has no effect //表达没有影响
GPIO_OUT = 0;
..\User\main.c(19): error:#29: expected an expression //预期的表达
GPIO_OUT = 0;
这是为什么啊
以下是原程序
# include "stm32f10x.h"
# include "bsp_led.h"
#define GPIO_OUT *((unsigned int *)((0x40010C0C & 0xF0000000) + 0x02000000 + ((0x40010C0C & 0x00FFFFFF)<<5) + (5<<2))) ;
int main(void)
{
GPIO_LED();
GPIO_OUT = 0;
} #define GPIO_OUT *((unsigned int *)((0x40010C0C & 0xF0000000) + 0x02000000 + ((0x40010C0C & 0x00FFFFFF)<<5) + (5<<2))) ;
GPIO_OUT = 0;
展开 =
*((unsigned int *)((0x40010C0C & 0xF0000000) + 0x02000000 + ((0x40010C0C & 0x00FFFFFF)<<5) + (5<<2))) ;= 0;
要把宏定义后面的分号去掉。
#define GPIO_OUT *((unsigned int *)((0x40010C0C & 0xF0000000) + 0x02000000 + ((0x40010C0C & 0x00FFFFFF)<<5) + (5<<2)))
qq1242009750 发表于 2018-1-12 22:11
#define GPIO_OUT *((unsigned int *)((0x40010C0C & 0xF0000000) + 0x02000000 + ((0x40010C0C & 0 ...
谢谢已经弄懂了{:5_92:}
页:
[1]