Skip to content

fix: include <any> in sstream_workaround.h to fix C++17 build#3346

Open
Felix-Gong wants to merge 1 commit into
apache:masterfrom
Felix-Gong:fix-std-any-cpp17
Open

fix: include <any> in sstream_workaround.h to fix C++17 build#3346
Felix-Gong wants to merge 1 commit into
apache:masterfrom
Felix-Gong:fix-std-any-cpp17

Conversation

@Felix-Gong

Copy link
Copy Markdown
Contributor

Summary

  • Fix std::any redeclaration error when building tests with C++17 and -Dprivate=public
  • The existing sstream_workaround.h already handles the same issue for <sstream>, but does not protect <any>

Fixes #3345

Test plan

  • Verified on x86 (GCC 13.3) and RISC-V (GCC 15.1) that the error reproduces with C++17 + -Dprivate=public
  • Verified the fix resolves the issue on both platforms
  • C++11/14 are unaffected (no std::any)

@chenBright chenBright left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using -fno-access-control, like in test/BUILD.bazel, would be more reasonable.

"-fno-access-control",

Comment thread test/sstream_workaround.h
# if __cplusplus >= 201703L
# include <any>
# endif
# define private public

@chenBright chenBright Jun 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using -fno-access-control instead of # define private public?

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.

-Dprivate=public in test CMakeLists.txt breaks std::any compilation with C++17

2 participants