7

I'm trying to compile an example stack trace displaying code. When I compile the test.c file with:

gcc -g -rdynamic ./test.c -o test

I get following error:

./test.c: In function ‘handler’:
./test.c:16: error: ‘STDERR_FILENO’ undeclared (first use in this function)
./test.c:16: error: (Each undeclared identifier is reported only once
./test.c:16: error: for each function it appears in.)

My includes are the same as in the original post code:

#include <stdio.h>
#include <execinfo.h>
#include <signal.h>
#include <stdlib.h>

My machine is ubuntu 13.04. Am I missing some library or haven't included something?

Community
  • 1
  • 1
ducin
  • 25,621
  • 41
  • 157
  • 256

1 Answers1

13

Also #include <unistd.h>.

See this GNU documentation.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242