Explicit Build Flags

Ensure build configuration explicitly sets (1) include paths and (2) required language/toolchain modes to prevent environment-dependent header resolution and compiler-mode breakages.

copy reviewer prompt

Prompt

Reviewer Prompt

Ensure build configuration explicitly sets (1) include paths and (2) required language/toolchain modes to prevent environment-dependent header resolution and compiler-mode breakages.

  • Include paths: Add third-party include directories explicitly and in a way that selects the intended headers. If a dependency’s headers conflict by name, adjust -I order/paths to avoid accidental inclusion of the wrong header.

    Example:

    # Prefer the dependency’s local includes to avoid header-name collisions
    CFLAGS += -I../deps/tre/local_includes
    
  • Language standard/toolchain mode: Do not rely on compiler defaults. Set the language standard required by the code (especially for C/C++ standard library features and syntax supported only in newer modes). If the code uses C99-only syntax (e.g., loop variable declarations), configure -std=c99 so older toolchains can compile successfully.

    Example:

    # Required because the code uses C99 syntax (e.g., for (size_t i = ...))
    STD ?= -std=c99
    CFLAGS += $(STD)
    

Apply this rule whenever you change a Makefile/feature flag/build script that depends on external headers or compiler behavior—treat build flags and include paths as configuration that must be deterministic across environments.

Source discussions