c99编译报错改用gnu99

使用c99编译出警告信息:implicit declaration of function ‘usleep’

按常规来讲,出现 “implicit declaration of function ‘xxxx’ ” 是因为头文件未包含导致的!

但是usleep的头文件unistd.h已经包含,让人很困惑!后来终于找到原因如下


原因:

原来是由于自己在编译时,为了可以for(int i; ...) 在Makefile中增加-std=c99导致的;


解决:

将-std=c99改为-std=gnu99

C99是直C99,GNU99是带有gnu扩展的C99。

clang支持-std选项,该选项更改clang使用的语言模式。 C支持的模式为c89,gnu89,c94,c99,gnu99以及这些模式的各种别名。 如果未指定-std选项,则clang默认为gnu99模式。

 

-std= 选择C语言编译标准

-std=
A value for this option must be provided; possible values are
`c99' `c9x' `iso9899:1999' `iso9899:199x'
ISO C99. Note that this standard is not yet fully supported; see http://gcc.gnu.org/c99status.htmlfor more information. The names `c9x' and `iso9899:199x' are deprecated. 

`gnu99' `gnu9x'
GNU dialect of ISO C99. When ISO C99 is fully implemented in GCC, this will become the default. The name `gnu9x' is deprecated. 
 

 

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值