Skip to content

Instantly share code, notes, and snippets.

@skyhisi
Created August 6, 2019 12:13
Show Gist options
  • Save skyhisi/e076644d3716d02e737a9917fb12b847 to your computer and use it in GitHub Desktop.
Save skyhisi/e076644d3716d02e737a9917fb12b847 to your computer and use it in GitHub Desktop.
Enable strict flags in a makefile for specific files
# Enable very strict flags for some files to ensure compatibility with
# all compilers (enables C99 strict compliance mode and more warnings).
STRICTFLAGS := \
-D_XOPEN_SOURCE --std=c99 -pedantic-errors -W -Wall -Wextra \
-Wno-variadic-macros -Wno-overlength-strings -fdiagnostics-show-option
STRICTFLAGS_FILES := \
file_a.c \
file_b.c
# Use '=' not ':=' to create a makefile macro
STRICTFLAGS_MACRO = $(if $(findstring $(notdir $<),$(STRICTFLAGS_FILES)),$(STRICTFLAGS))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment