Why can't gcc find the random() interface when -std=c99 is set?

前端 未结 4 1800
借酒劲吻你
借酒劲吻你 2020-12-15 06:26

I do \"#include \" at the top of the source.

Example compilation:

/usr/bin/colorgcc -std=c99 -fgnu89-inline  -g -Wall -I         


        
4条回答
  •  温柔的废话
    2020-12-15 06:36

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

    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
    

提交回复
热议问题