Skip to content

fix: guard HAVE_MAT_LIVEEVENTINSPECTOR/PRIVACYGUARD against redefinition#1473

Merged
bmehta001 merged 3 commits into
microsoft:mainfrom
bmehta001:bhamehta/fix-config-default-redefine
Jun 10, 2026
Merged

fix: guard HAVE_MAT_LIVEEVENTINSPECTOR/PRIVACYGUARD against redefinition#1473
bmehta001 merged 3 commits into
microsoft:mainfrom
bmehta001:bhamehta/fix-config-default-redefine

Conversation

@bmehta001

@bmehta001 bmehta001 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

The modules-repo (cpp_client_telemetry_modules) CI workflow build-posix-latest-exp has been failing on Linux and macOS for ~2 weeks with:

lib/include/mat/config-default.h:36: error: 'HAVE_MAT_LIVEEVENTINSPECTOR' macro redefined [-Werror,-Wmacro-redefined]
lib/include/mat/config-default.h:37: error: 'HAVE_MAT_PRIVACYGUARD' macro redefined [-Werror,-Wmacro-redefined]

Root cause

When BUILD_LIVEEVENTINSPECTOR / BUILD_PRIVACYGUARD (default YES) is on and the respective module dir exists, tests/functests/CMakeLists.txt and tests/unittests/CMakeLists.txt add -DHAVE_MAT_LIVEEVENTINSPECTOR / -DHAVE_MAT_PRIVACYGUARD to the compile command. The three config-default*.h headers then #define the same macros unconditionally. With -Werror (added by #1415), the -Wmacro-redefined warning becomes fatal on GCC/Clang.

Other macros in the same block (HAVE_MAT_JSONHPP, HAVE_MAT_ZLIB, HAVE_MAT_STORAGE, etc.) are not added by CMake -D flags, so this only affects these two.

Fix

Wrap the two #defines in #ifndef guards in all three config-default*.h headers (config-default.h, config-default-cs4.h, config-default-exp.h). Pure-additive:

  • No command-line -D: header defines them as before. Unchanged.
  • With command-line -D: header skips the redefine, no warning.

Verification

@bmehta001 bmehta001 requested a review from a team as a code owner June 10, 2026 18:45
Under -Werror on Linux/macOS, the modules-repo CI (build-posix-latest-exp)
has been failing for ~2 weeks with:

  config-default.h:36: error: 'HAVE_MAT_LIVEEVENTINSPECTOR' macro redefined
                              [-Werror,-Wmacro-redefined]
  config-default.h:37: error: 'HAVE_MAT_PRIVACYGUARD' macro redefined

tests/functests/CMakeLists.txt and tests/unittests/CMakeLists.txt add
-DHAVE_MAT_LIVEEVENTINSPECTOR / -DHAVE_MAT_PRIVACYGUARD on the command
line when BUILD_LIVEEVENTINSPECTOR / BUILD_PRIVACYGUARD (default YES) and
the respective module dir exists. The three config-default headers then
redefined them unconditionally, which is fatal under -Werror (added by
microsoft#1415).

Wrapping the two defines in #ifndef in all three config-default*.h
headers preserves all existing behavior:
- Without command-line -D: macros get defined here as before.
- With command-line -D: header skips the redefinition, no warning.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001 bmehta001 force-pushed the bhamehta/fix-config-default-redefine branch from 75910a5 to 7b43dd4 Compare June 10, 2026 18:48
@bmehta001

Copy link
Copy Markdown
Contributor Author

Force-pushed to extend the fix to all three config-default*.h headers (config-default-cs4.h, config-default-exp.h had the same unconditional defines). Same trivial 2-line guard per file. Verified no conflict with #1466.

@bmehta001 bmehta001 self-assigned this Jun 10, 2026
@bmehta001 bmehta001 merged commit e2f7aec into microsoft:main Jun 10, 2026
34 checks passed
@bmehta001 bmehta001 deleted the bhamehta/fix-config-default-redefine branch June 10, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants