【error: expected identifier or ‘(‘ before ‘int‘ int abs (int);】

报错信息:
stdlib.h:70:5: error: expected identifier or '(' before 'int'
 int abs (int);
     ^~~

这个错误是在.c文件开头添加了

#include <stdlib.h>

头文件包含后,编译出现的。
觉得十分奇怪,包含标准库头文件为什么会编译报错呢?
我的头文件包含情况是:

#include "user_data_config.h"
#include "json_deal_with.h"
#include "desktop_scene.h"
#include "cJSON.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <typedef.h>

其中,user_data_config.h 是我自己编写的头文件。
这样的顺序下,编译就会报上面哪个错误。
修改为

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <typedef.h>
#include "user_data_config.h"
#include "json_deal_with.h"
#include "desktop_scene.h"
#include "cJSON.h"

后再编译,竟然不报错了,看来头文件包含也是有顺序要求的,标准库要放在前面,避免自己定义的头文件里引入了内容影响到标准库吧。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值