From 1318f72988793017f756d574c4aa7f409349fca3 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 5 Oct 2018 14:37:26 +0800 Subject: [PATCH] Define feature macros only on Linux This patch makes it working on BSD (tested on DragonFly BSD, should be the same on FreeBSD). Fix issue: https://github.com/nsf/termbox/issues/110 On Linux, such features macros (_POSIX_C_SOURCE, _XOPEN_SOURCE) are required to expose more functions. However, on *BSD, almost everything is exposed when no feature macros are defined, while defining feature macros would restrict the functions to be exposed. See more information at: https://lists.freebsd.org/pipermail/freebsd-standards/2004-March/000474.html --- makefile | 5 +++++ src/term.c | 1 - src/termbox.c | 2 -- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index 3cb9c19..4f6acc5 100644 --- a/makefile +++ b/makefile @@ -2,6 +2,11 @@ NAME=termbox CC=gcc FLAGS=-std=c99 -pedantic -Wall -Werror -g +OS:=$(shell uname -s) +ifeq ($(OS),Linux) + FLAGS+=-D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE +endif + BIND=bin SRCD=src OBJD=obj diff --git a/src/term.c b/src/term.c index 298bf9d..c94f394 100644 --- a/src/term.c +++ b/src/term.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/src/termbox.c b/src/termbox.c index 8c14e30..72a4335 100644 --- a/src/termbox.c +++ b/src/termbox.c @@ -1,5 +1,3 @@ -#define _POSIX_C_SOURCE 200809L -#define _XOPEN_SOURCE #include "term.h" #include "termbox.h" #include "memstream.h"