nsf / termbox

Library for writing text-based user interfaces
http://code.google.com/p/termbox
MIT License
1.96k stars 185 forks source link

Build failure on OpenBSD: SIGWINCH #110

Open vext01 opened 6 years ago

vext01 commented 6 years ago
$ ./waf
Waf: Entering directory `/home/edd/source/termbox/build'
[ 1/12] c: src/termbox.c -> build/src/termbox.c.1.o
[ 2/12] c: src/utf8.c -> build/src/utf8.c.1.o
[ 3/12] c: src/termbox.c -> build/src/termbox.c.2.o
[ 4/12] c: src/utf8.c -> build/src/utf8.c.2.o
../src/termbox.c: In function 'tb_init_fd':
../src/termbox.c:99: error: 'SIGWINCH' undeclared (first use in this function)
../src/termbox.c:99: error: (Each undeclared identifier is reported only once
../src/termbox.c:99: error: for each function it appears in.)

../src/termbox.c: In function 'tb_init_fd':
../src/termbox.c:99: error: 'SIGWINCH' undeclared (first use in this function)
../src/termbox.c:99: error: (Each undeclared identifier is reported only once
../src/termbox.c:99: error: for each function it appears in.)

Waf: Leaving directory `/home/edd/source/termbox/build'
Build failed
 -> task in 'termbox_shared' failed (exit status 1): 
        {task 7395741466256: c termbox.c -> termbox.c.1.o}
['/usr/bin/gcc', '-std=gnu99', '-Wall', '-Wextra', '-D_XOPEN_SOURCE', '-O3', '-fPIC', '../src/termbox.c', '-c', '-o', '/home/edd/source/termbox/build/src/termbox.c.1.o']
 -> task in 'termbox_static' failed (exit status 1): 
        {task 7395741577296: c termbox.c -> termbox.c.2.o}
['/usr/bin/gcc', '-std=gnu99', '-Wall', '-Wextra', '-D_XOPEN_SOURCE', '-O3', '../src/termbox.c', '-c', '-o', '/home/edd/source/termbox/build/src/termbox.c.2.o']

The fix is to set __BSD_VISIBLE to 1 before including <signal.h>.

In <signal.h>:

...
#define SIGVTALRM 26    /* virtual time alarm */
#define SIGPROF 27  /* profiling time alarm */
#if __BSD_VISIBLE
#define SIGWINCH 28 /* window size changes */
#define SIGINFO 29  /* information request */
#endif
#define SIGUSR1 30  /* user defined signal 1 */
#define SIGUSR2 31  /* user defined signal 2 */
...

Cheers.

rofl0r commented 6 years ago

__BSD_VISIBLE is an internal macro, that's not the right fix. you need to use the right feature test macro http://man7.org/linux/man-pages/man7/feature_test_macros.7.html