Skip to content

Commit 800e971

Browse files
Copilotithewei
andcommitted
Use -std=gnu99 globally on Linux instead of per-file override for io_uring.c
Co-authored-by: ithewei <26049660+ithewei@users.noreply.github.com>
1 parent bcb6f28 commit 800e971

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hconfig.h.in ${CMAKE_CURRENT_SOURCE_D
104104
# see Makefile.in
105105
set(CMAKE_C_STANDARD 99)
106106
set(CMAKE_C_STANDARD_REQUIRED True)
107+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_C_COMPILER_ID STREQUAL "GNU")
108+
set(CMAKE_C_EXTENSIONS ON)
109+
endif()
107110
set(CMAKE_CXX_STANDARD 11)
108111
set(CMAKE_CXX_STANDARD_REQUIRED True)
109112

@@ -174,8 +177,6 @@ if(WITH_IO_URING)
174177
message(FATAL_ERROR "WITH_IO_URING is only supported on Linux because liburing is Linux-only.")
175178
endif()
176179
set(LIBS ${LIBS} uring)
177-
# liburing headers require GNU C extensions (typeof, statement expressions, etc.)
178-
set_source_files_properties(event/io_uring.c PROPERTIES COMPILE_OPTIONS "-std=gnu99")
179180
endif()
180181

181182
if(WIN32 OR MINGW)

Makefile.in

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ endif
8787
endif
8888

8989
ifeq ($(findstring -std, $(CFLAGS)), )
90+
ifeq ($(OS), Linux)
91+
override CFLAGS += -std=gnu99
92+
else
9093
override CFLAGS += -std=c99
9194
endif
95+
endif
9296

9397
ifeq ($(findstring -std, $(CXXFLAGS)), )
9498
override CXXFLAGS += -std=c++11
@@ -199,13 +203,6 @@ ifeq ($(WITH_IO_URING), yes)
199203
endif
200204
endif
201205

202-
# liburing headers require GNU C extensions (typeof, statement expressions, etc.)
203-
ifeq ($(OS), Linux)
204-
ifeq ($(WITH_IO_URING), yes)
205-
event/io_uring.o: event/io_uring.c
206-
$(CC) $(CPPFLAGS) $(CFLAGS) -std=gnu99 -c $< -o $@
207-
endif
208-
endif
209206

210207
LDFLAGS += $(addprefix -L, $(LIBDIRS))
211208
LDFLAGS += $(addprefix -l, $(LIBS))

0 commit comments

Comments
 (0)