Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why gcc gives warning: implicit declaration of function qsort_r?

Tags:

c

gcc

I do include<stdlib.h> where qsort_r is given. And I use gcc -std=c99 -O3 myfun.c -o myfun to compile.

It compiles, links and runs well. I don't know why I got this warning and what is potential risk of this warning ?

BTW, my compiler is gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)

like image 732
notbad Avatar asked Feb 14 '23 08:02

notbad


1 Answers

It does so because you use -std=c99 , there's no qsort_r function in stdlib.h in c99.

Use -std=gnu99 to make the extensions available, or add a #define _GNU_SOURCE to your source files before including the header files.

like image 131
nos Avatar answered Apr 27 '23 09:04

nos