如何解决error: #268问题:声明不得出现在可执行语句之后的方法
在stm32f407编程中遇到了error: #268: declaration may not appear after executable statement in block,编写代码如下:
#include "bsp_led.h"
void GPIO_Config(void)
{
/*以下四个步骤适用于所有的外设成员*/
/*第一步:开GPIO外设时钟*/
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);
/*第二步:定义一个GPIO初始化结构体*/
GPIO_InitTypeDef GPIO_InitStruct;
/*第三步:配置GPIO初始化结构体成员*/
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;//引脚:GPIOF_6
GPIO_InitStruct.GPIO_Mode= GPIO_Mode_OUT;//输出模式
GPIO_InitStruct.GPIO_OType=GPIO_OType_PP;//推挽输出
GPIO_InitStruct.GPIO_Speed=GPIO_Low_Speed;//输出速度:LOW
GPIO_InitStruct.GPIO_PuPd=GPIO_PuPd_UP;//上拉,高电压
/*第四步:调用GPIO初始化函数,把配置好的GPIO初始化成员写入寄存器*/
GPIO_Init(GPIOF, &GPIO_InitStruct);
}
报错情况:
问题分析:
解决方法: