当-std = C99设置为什么不能gcc的发现随机的()接口? [英] Why can't gcc find the random() interface when -std=c99 is set?

查看:440
本文介绍了当-std = C99设置为什么不能gcc的发现随机的()接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#&包括LT; stdlib.h中>中在源代码的顶部

例如编译:

/usr/bin/colorgcc -std=c99 -fgnu89-inline  -g -Wall -I/usr/include -I./ -I../ -I../../ -I../../../ -I../../../../    -O3 -o f8  f8.c
In file included from f8.c:7:
ctype-cmp.c: In function ‘randomized’:
ctype-cmp.c:48: warning: implicit declaration of function ‘random’
ctype-cmp.c: In function ‘main’:
ctype-cmp.c:153: warning: implicit declaration of function ‘srandom’
ais@xcalibur:t$ 

当我关闭-std = C99,功能ISFINITE()无法找到。所以我想使用-std = C99,这和其他原因。有一些诀窍,我失踪?

When I turn off -std=c99, the function isfinite() can not be found. So I do want to use -std=c99 for this and other reasons. Is there some trick I'm missing?

推荐答案

男人srandom 表示,该功能的的C99的一部分,但部分POSIX的。

man srandom says that the function is not part of C99 but part of POSIX.

激活 _BSD_SOURCE _XOPEN_SOURCE> = 500 或任何其他合适的功能测试宏声明的srandom /随机功能(见男人feature_test_macros 男人srandom )。

Activate _BSD_SOURCE or _XOPEN_SOURCE >= 500 or any other suitable feature test macro that declares the srandom/random function (see man feature_test_macros and man srandom).

这人有很好的机会,但是你需要通过阅读上面的手册页找出被定义/不隐式定义,从而太宏。

This one has good chances, but you need to figure out the macros that are defined/not defined implicitly thereby too by reading the manpages above.

/usr/bin/colorgcc -std=c99 -D_XOPEN_SOURCE=600 -fgnu89-inline -g -Wall 
    -I/usr/include -I./ -I../ -I../../ -I../../../ -I../../../../ -O3 -o f8  f8.c

这篇关于当-std = C99设置为什么不能gcc的发现随机的()接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆