Bug#176910: libc6-dev: "kill" prototype not included from signal.h in -ansi mode
At Wed, 15 Jan 2003 20:50:03 +0000,
Steven J. Murdoch <debianbts+Steven.Murdoch@cl.cam.ac.uk> wrote:
> Package: libc6-dev
> Version: 2.2.5-11.2
> Severity: normal
>
> In "man 2 kill" the required include files for the function:
> int kill(pid_t pid, int sig);
> are:
> #include <sys/types.h>
> #include <signal.h>
>
> However when a program is compiled in -ansi mode the required prototype
> is not included. In the normal compilation mode the prototype is
> included from /usr/include/signal.h
>
> For example:-
> --- BEGIN LOG ---
> sjm217@maxwell:~/tmp$ cat libc6-dev-test.c
> #include <sys/types.h>
> #include <signal.h>
>
> int main(void) {
> kill(0,0);
> return 0;
> }
>
> sjm217@maxwell:~/tmp$ gcc -Wall -ansi -pedantic libc6-dev-test.c
> libc6-dev-test.c: In function `main':
> libc6-dev-test.c:5: warning: implicit declaration of function `kill'
>
> sjm217@maxwell:~/tmp$ gcc -Wall -ansi libc6-dev-test.c
> libc6-dev-test.c: In function `main':
> libc6-dev-test.c:5: warning: implicit declaration of function `kill'
>
> sjm217@maxwell:~/tmp$ gcc -Wall libc6-dev-test.c
>
> sjm217@maxwell:~/tmp$
>
> --- END LOG ---
>
> I would have expected that either the kill(2) manpage noted the correct
> header files that need to be included, or the sys/types.h and signal.h
> header files to be modified to include the prototype of kill.
>
> Please let me know if any more information is required.
info libc:
If you are concerned about strict adherence to the ISO C
standard, you should use the `-ansi' option when you compile
your programs with the GNU C compiler. This tells the
compiler to define _only_ ISO standard features from the
library header files, unless you explicitly ask for additional
features. *Note Feature Test Macros::, for information on how
to do this.
Of cource, ISO C does not have kill(2), it's BSD/POSIX/XPG feature.
Use gcc -std={gnu89,gnu99,gnu9x}, or set gcc
-D{_GNU_SOURCE,_XOPEN_SOURCE,_POSIX_SOURCE} instead.
Regards,
-- gotom
Reply to: