Merge pull request #14738 from benpicco/c11

CODING_CONVENTIONS.md: default to C11
This commit is contained in:
benpicco 2021-02-15 10:42:54 +01:00 committed by GitHub
commit ffdddc802e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 6 deletions

View File

@ -2,7 +2,7 @@
## General ## General
* Code shall be [C99](http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf) * Code shall be [C11](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf)
compliant. compliant.
* Avoid dynamic memory allocation (malloc/free, new, etc.)! It will break * Avoid dynamic memory allocation (malloc/free, new, etc.)! It will break
real-time guarantees, increase code complexity, and make it more likely to use real-time guarantees, increase code complexity, and make it more likely to use

View File

@ -23,7 +23,7 @@ export GPROF ?= gprof
CFLAGS += -Wall -Wextra -pedantic $(CFLAGS_DBG) CFLAGS += -Wall -Wextra -pedantic $(CFLAGS_DBG)
CFLAGS_DBG ?= -g3 CFLAGS_DBG ?= -g3
# default std set to gnu99 of not overwritten by user # default std set to gnu11 if not overwritten by user
ifeq (,$(filter -std=%, $(CFLAGS))) ifeq (,$(filter -std=%, $(CFLAGS)))
CFLAGS += -std=gnu11 CFLAGS += -std=gnu11
endif endif

View File

@ -1,8 +1,8 @@
# Test if the input language was specified externally. # Test if the input language was specified externally.
# Otherwise test if the compiler unterstands the "-std=c99" flag, and use it if so. # Otherwise test if the compiler unterstands the "-std=c11" flag, and use it if so.
ifeq ($(filter -std=%,$(CFLAGS)),) ifeq ($(filter -std=%,$(CFLAGS)),)
ifeq ($(shell $(CC) -std=c99 -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) ifeq ($(shell $(CC) -std=c11 -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
CFLAGS += -std=c99 CFLAGS += -std=c11
endif endif
endif endif

View File

@ -29,7 +29,7 @@ $(PKG_BUILD_DIR)/lib/librelic_s.a: $(PKG_BUILD_DIR)/Makefile
# Pass 'COMP' with a target specific export to not have issues with the shell # Pass 'COMP' with a target specific export to not have issues with the shell
# escaping evaluation. # escaping evaluation.
COMP = $(filter-out -Werror -Werror=old-style-definition -Werror=strict-prototypes -std=gnu99,$(CFLAGS)) COMP = $(filter-out -Werror -Werror=old-style-definition -Werror=strict-prototypes -std=gnu11,$(CFLAGS))
$(PKG_BUILD_DIR)/Makefile: export COMP ?= $(PKG_BUILD_DIR)/Makefile: export COMP ?=
$(PKG_BUILD_DIR)/Makefile: $(PKG_PREPARED) $(TOOLCHAIN_FILE) | ..cmake_version_supported $(PKG_BUILD_DIR)/Makefile: $(PKG_PREPARED) $(TOOLCHAIN_FILE) | ..cmake_version_supported
cmake -B$(PKG_BUILD_DIR) -H$(PKG_SOURCE_DIR) \ cmake -B$(PKG_BUILD_DIR) -H$(PKG_SOURCE_DIR) \