Skip to content

Commit

Permalink
Merge pull request #10012 from orbea/c99
Browse files Browse the repository at this point in the history
qb: Improve the gnu99 compiler check.
  • Loading branch information
inactive123 authored Jan 15, 2020
2 parents fca5af7 + 4171c93 commit 9e25601
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
24 changes: 10 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ ifneq ($(findstring Win32,$(OS)),)
LDFLAGS += -mwindows
endif

ifneq ($(CXX_BUILD), 1)
ifneq ($(C89_BUILD),)
CFLAGS += -std=c89 -ansi -pedantic -Werror=pedantic -Wno-long-long
else ifeq ($(HAVE_C99), 1)
CFLAGS += $(C99_CFLAGS)
endif

CFLAGS += -D_GNU_SOURCE
endif

DEF_FLAGS += -Wall $(INCLUDE_DIRS) -I. -Ideps -Ideps/stb

CFLAGS += $(DEF_FLAGS)
Expand All @@ -127,20 +137,6 @@ else
LINK = $(CC)
endif

ifneq ($(CXX_BUILD), 1)
ifneq ($(GNU90_BUILD), 1)
ifneq ($(findstring icc,$(CC)),)
CFLAGS += -std=c99 -D_GNU_SOURCE
else
CFLAGS += -std=gnu99 -D_GNU_SOURCE
endif
endif

ifneq ($(C89_BUILD),)
CFLAGS += -std=c89 -ansi -pedantic -Werror=pedantic -Wno-long-long
endif
endif

ifeq ($(NOUNUSED), yes)
CFLAGS += -Wno-unused-result
CXXFLAGS += -Wno-unused-result
Expand Down
8 changes: 7 additions & 1 deletion qb/config.libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
# Only needed when check_enabled ($2), check_platform, check_lib, check_pkgconf,
# check_header, check_macro and check_switch are not used.

check_switch '' C99 -std=gnu99 "Cannot find C99 compatible compiler."
check_switch '' C99 -std=gnu99 ''

if [ "$HAVE_C99" = 'no' ]; then
HAVE_C99='auto'
check_switch '' C99 -std=c99 'Cannot find a C99 compatible compiler.'
fi

check_switch cxx CXX11 -std=c++11 ''
check_switch '' NOUNUSED -Wno-unused-result ''
add_define MAKEFILE NOUNUSED "$HAVE_NOUNUSED"
Expand Down

0 comments on commit 9e25601

Please sign in to comment.