illegal statement termination skipping `unsigned' `char'
量定义写在引脚定义的后面就出错。写在开头可以编译通过。
C/C++ code
void main(void){
unsigned char BT_FLG;
DDRA = 0x00; /*方向输入*/
PORTA = 0xFF; /*打开上拉*/
DDRB = 0xFF; /*方向输出*/
PORTB = 0xFF; /*高电平*/
DDRC = 0x00;
PORTC = 0xFF;
DDRD = 0x00;
PORTD = 0xFF;
Uart_Init();
//unsigned char BT_FLG;//写在这个位置就出错
错误信息:
!E E:\AVR\示例程序\0010-UART-LED-B\b_uart.c(57): illegal statement termination
!E E:\AVR\示例程序\0010-UART-LED-B\b_uart.c(57): skipping `unsigned' `char'
!E E:\AVR\示例程序\0010-UART-LED-B\b_uart.c(57): undeclared identifier `BT_FLG'
!W E:\AVR\示例程序\0010-UART-LED-B\b_uart.c(57):[warning] expression with no effect elided
====================================
请问是编译器的原因还是单片机程序里位置有严格要求?
C语言明确规定,变量定义要在代码语句前,又不是C++编译器。 基础知识要扎实。