我是靠谱客的博主 健壮棉花糖,这篇文章主要介绍错题本1:main.c(4): error C141: syntax error near ‘u16‘, expected ‘hdata‘,现在分享给大家,希望可以做个参考。

首先主函数如下:

复制代码
1
2
3
4
5
6
7
8
9
10
11
#include "reg52.h" #include "uart.h" typedef unsigned int u16; typedef unsigned char u8; void main() { UartInit(); while(1); }

uart.h文件:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef __UART_H #define __UART_H typedef unsigned int u16; typedef unsigned char u8; void UartInit(); #endif

编译后的现象:

复制代码
1
2
3
4
5
6
7
8
Rebuild started: Project: Usart1 Rebuild target 'Target 1' compiling main.c... main.c(4): error C141: syntax error near 'u16', expected 'hdata' main.c(5): error C231: 'u8': redefinition compiling uart.c... Target not created. Build Time Elapsed: 00:00:00

        编译后出现以上问题,找了半天,把uart.h中的下面这两句放到uart.c中就没问题了,具体什么原因,还不知道。

复制代码
1
2
typedef unsigned int u16; typedef unsigned char u8;

修改后的uart.h如下:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef __UART_H #define __UART_H void UartInit(); #endif

最后

以上就是健壮棉花糖最近收集整理的关于错题本1:main.c(4): error C141: syntax error near ‘u16‘, expected ‘hdata‘的全部内容,更多相关错题本1:main.c(4):内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(75)

评论列表共有 0 条评论

立即
投稿
返回
顶部