Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use strsignal and WCOREDUMP in ANSI C?
    primarykey
    data
    text
    <p>I've been trying to learn C the hard way - issuing basic calls, watching them fail, and trying to figure out what's going on. At the moment I'm working with fork() and the interoperation between parent and child processes. Everything has worked as expected, except tonight when I introduced <code>-ansi</code> into my CFLAGS. At that point, I got these messages from make:</p> <pre><code>waitpid.c: In function ‘wait_for_child’: waitpid.c:63:3: warning: implicit declaration of function ‘strsignal’ [-Wimplicit-function-declaration] printf("child exited with signal %s\n", strsignal(WTERMSIG(child_status))); ^ waitpid.c:63:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=] waitpid.c:64:3: warning: implicit declaration of function ‘WCOREDUMP’ [-Wimplicit-function-declaration] if ( WCOREDUMP(child_status) ) { ^ </code></pre> <p>The output of <code>gcc -C -E</code> is radically different depending on whether I specify -ansi as well. Both show expansions of WIFEXITED, WEXITSTATUS, WIFSIGNALED, and WTERMSIG, but only the non-ANSI version expands WCOREDUMP. It's also the one that gets a declaration of strsignal from sys/wait.h.</p> <p>I infer that strsignal and WCOREDUMP aren't supported in ANSI C, though I can't find anything explicit yet that says so. Is there some other way to perform their functions? Or am I missing something basic?</p> <p>Full code is at <a href="http://pastebin.com/hQ2pR7fF" rel="nofollow">http://pastebin.com/hQ2pR7fF</a>. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload