标题:
关于单片机C语言预定义 #define u8 unsigned short;
[打印本页]
作者:
fxl1111
时间:
2020-4-11 15:55
标题:
关于单片机C语言预定义 #define u8 unsigned short;
已经在主函数外预定义过u8就是unsigned short。为什么u8 number[10]会报错,而unsigned short number[10]则没有问题。谢谢
#define u8 unsigned short;
u8 jian (void);
void main (void)
{
unsigned short number[10]
={
0x11,0x23,0x24,0x54,0x23,0x12,0x65,0x76,0x38,0x71};
作者:
gb302
时间:
2020-4-11 17:27
语法错误,多了一个分号
作者:
angmall
时间:
2020-4-11 17:48
#define u8 unsigned short
;
你的定义有多余的分号
作者:
game灬boy
时间:
2020-4-11 19:58
是不是u8在其他地方被宏定义了,你再定义就是重定义了,具体原因你得看报错是什么啊
作者:
ubun16.04
时间:
2020-4-11 22:42
别加分号,不然替换的时候会把分号一起加进去就出错了
作者:
黄youhui
时间:
2020-4-13 08:40
你的宏定义后面加了分号,另外u8很多大佬在历程中宏定义为unsigned char,你定义unsigned short最好不要用u8。unsigned short 应该时是和int一样的16位的,你定义成u16
typedef unsigned char u8;
typedef unsigned short int u16;
typedef unsigned int u32;
typedef unsigned __INT64 u64;
typedef signed char int8_t;
typedef signed short int int16_t;
typedef signed int int32_t;
typedef signed __INT64 int64_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __INT64 uint64_t;
作者:
fxl1111
时间:
2020-4-13 15:56
黄youhui 发表于 2020-4-13 08:40
你的宏定义后面加了分号,另外u8很多大佬在历程中宏定义为unsigned char,你定义unsigned short最好不要用u ...
建议非常好,谢谢
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1