简体   繁体   中英

Why gcc gives warning: implicit declaration of function qsort_r?

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)

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.

qsort_r is not supported by C99. Specification says nothing about it.

Language Standards Supported by GCC :

By default, GCC provides some extensions to the C language that on rare occasions conflict with the C standard 1 . See Extensions to the C Language Family. Use of the -std options listed above will disable these extensions where they conflict with the C standard version selected. You may also select an extended version of the C language explicitly with -std=gnu89 (for C89 with GNU extensions) or -std=gnu99 (for C99 with GNU extensions). The default, if no C language dialect options are given, is -std=gnu89; this will change to -std=gnu99 in some future release when the C99 support is complete. Some features that are part of the C99 standard are accepted as extensions in C89 mode.


1. Emphasis is mine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM