Problems turning on -Werror

For local gcc-arm builds (including Workbench local builds) I was able to do this for user firmware by adding a build.mk file in the src directory with the following contents:

# Standard behavior must be included here
INCLUDE_DIRS += $(SOURCE_PATH)/$(USRSRC)  # add user sources to include path
CPPSRC += $(call target_files,$(USRSRC_SLASH),*.cpp)
CSRC += $(call target_files,$(USRSRC_SLASH),*.c)

APPSOURCES=$(call target_files,$(USRSRC_SLASH),*.cpp)
APPSOURCES+=$(call target_files,$(USRSRC_SLASH),*.c)

# Custom stuff can be added here

# Make all warnings fatal
EXTRA_CFLAGS += -Werror -Wfatal-errors

There’s still a little boilerplate at the top that’s unfortunate, but using EXTRA_CFLAGS is much better than having to replicate the actual CFLAGS values. And it doesn’t require modifying the Device OS source.

Note that the build.mk file must be in src, not the top level where project.properties is.

Also, if you edit build.mk, it does not automatically force rebuild so you may need to clean application.

It does not work with the cloud compilers (CLI or cloud compile from workbench).

1 Like