编译报错
学习使用Keil的时候,build报错
User\main.c(6): error: #268: declaration may not appear after executable statement in block
GPIO_InitTypeDef GPIO_InitStructure;
学习代码如下:
#include "stm32f10x.h" // Device header int main(void) { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_SetBits(GPIOC, GPIO_Pin_13); // GPIO_ResetBits(GPIOC, GPIO_Pin_13); while (1) { } }
解决方法
勾选c99 mode
c99 mode: 定义变量的位置可以不设置在开头,定义在任意位置
- declaration executable statement appear afterdeclaration executable statement appear mysqldump statement appeared时报 statement executing password before skip-grant-tables statement execute running execution interrupted statement exceeded lock_write_growth statement execute running appears appear appeared connection retrying appears network