首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

写ARM的C程序遇到的一点小疑点

2012-08-11 
写ARM的C程序遇到的一点小问题小弟在用C写ARM的程序时候,碰到一点小问题,一直没明白,请高手给指点下:C/C++

写ARM的C程序遇到的一点小问题
小弟在用C写ARM的程序时候,碰到一点小问题,一直没明白,请高手给指点下:

C/C++ code
#include <stdio.h>                       /* standard I/O .h-file              */#include <ctype.h>                       /* character functions               */#include <LPC23xx.H>  #include "config.h"//提示错误的头文件#include "I2CINT.h"int main(void){//锁定PLLPLLCON = 1; // 使能PLLPLLCFG = 0xB; // 设置M 为6,P 为2PLLFEED = 0xAA; // 发送PLL 馈送序列PLLFEED = 0x55;      while((PLLSTAT & (1 << 26)) == 0); // 等待PLL 锁定PLLCON = 3; // PLL使能和连接PLLFEED = 0xAA; // 发送PLL 馈送序列PLLFEED = 0x55;//配置管脚PINSEL0=0xC0000050;PINSEL1=0x014043FF;PINSEL3=0x00000000;PINSEL2=0x01500000;//RTC地址0XEB//uint8 I2C_ReadNByte (uint8 sla, uint32 suba_type, uint32 suba, uint8 *s, uint32 num);#define RTC 0xEB#define RTC_sec 0x00uint8 sec;//问题出在这里,uint8在config.h头文件里面定义//I2C_ReadNByte(RTC,ONE_BYTE_SUBA,RTC_sec,sec,1);sec=1;//还有这里}

C/C++ code
#ifndef __CONFIG_H#define __CONFIG_H// 不能被更改#ifndef TRUE#define TRUE 1#endif#ifndef FALSE#define FALSE 0#endiftypedef unsigned char uint8; /* 无符号8 位整型变量 */typedef signed char int8; /* 有符号8 位整型变量 */typedef unsigned short uint16; /* 无符号16 位整型变量 */typedef signed short int16; /* 有符号16 位整型变量 */typedef unsigned int uint32; /* 无符号32 位整型变量 */typedef signed int int32; /* 有符号32 位整型变量 */typedef float fp32; /* 单精度浮点数(32 位长度) */typedef double fp64; /* 双精度浮点数(64 位长度) */#endif

提示的错误也提出来,高手给看看:
main.c(32): error: #268: declaration may not appear after executable statement in block
main.c: uint8 sec;
main.c: ^
main.c(32): error: #67: expected a "}"
main.c: uint8 sec;
main.c: ^
main.c(34): error: #77-D: this declaration has no storage class or type specifier
main.c: sec=1;
main.c: ^
main.c(34): error: #147: declaration is incompatible with "uint8 sec" (declared at line 32)
main.c: sec=1;
main.c: ^
main.c(35): error: #169: expected a declaration
main.c: }
main.c: ^
main.c: main.c: 0 warnings, 5 errors

[解决办法]
main.c(32): error: #268: declaration may not appear after executable statement in block
这里说了, 变量声明不允许出现在语句之后.
把uint8 sec;这一行移到函数最开头去吧

热点排行
Bad Request.