Skip to content

Commit

Permalink
Define feature macros only on Linux
Browse files Browse the repository at this point in the history
This patch makes it working on BSD (tested on DragonFly BSD, should be
the same on FreeBSD).  Fix issue: nsf#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
  • Loading branch information
liweitianux committed Oct 5, 2018
1 parent 09ee796 commit db62450
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 5 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/term.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
2 changes: 0 additions & 2 deletions src/termbox.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#define _XOPEN_SOURCE
#include "term.h"
#include "termbox.h"
#include "memstream.h"
Expand Down

0 comments on commit db62450

Please sign in to comment.