[CODE HEALTH] Move func_http_main classes into anonymous namespace#4128
Merged
marcalff merged 1 commit intoJun 6, 2026
Merged
Conversation
Wraps the 3 file-scope class and struct declarations in functional/otlp/func_http_main.cc within an anonymous namespace to give them internal linkage and clear the misc-use-internal-linkage warnings clang-tidy reports on this file. The wrap covers TestResult (line 62), TestLogHandler (line 145), and test_case (line 333). It deliberately ends BEFORE the static int test_*() forward declarations at line 339+. This boundary matters: the test_*() declarations are matched by definitions in the lower half of the file (lines 1484-1882, after main()). Wrapping the declarations alone would create (anonymous namespace)::test_* symbols that fail to link against the file-scope static test_*() definitions. Verified locally: extending the wrap to line 453 produced 12+ undefined reference linker errors; the shortened wrap ending at line 337 builds cleanly (121/121 ninja steps for func_otlp_http target with WITH_OTLP_HTTP=ON). main() and all test_*() infrastructure (declarations, the all_tests[] table, list_test_cases, run_test_case, and definitions) remain at file scope with their existing static linkage. Ratchet: * abiv1-preview warning_limit lowered from 352 to 349 * abiv2-preview warning_limit lowered from 356 to 353 Part of open-telemetry#2053 Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
ac756ae to
2cc3267
Compare
marcalff
approved these changes
Jun 6, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4128 +/- ##
==========================================
- Coverage 81.95% 81.94% -0.01%
==========================================
Files 385 385
Lines 16067 16067
==========================================
- Hits 13166 13164 -2
- Misses 2901 2903 +2 🚀 New features to boost your workflow:
|
4 tasks
thc1006
added a commit
to thc1006/opentelemetry-cpp
that referenced
this pull request
Jun 6, 2026
Wraps the 3 file-scope class and struct declarations in functional/otlp/func_grpc_main.cc within an anonymous namespace to give them internal linkage and clear the misc-use-internal-linkage warnings clang-tidy reports on this file. The wrap covers TestResult (line 63), TestLogHandler (line 128), and test_case (line 316). It deliberately ends BEFORE the static int test_*() forward declarations at line 322+. This boundary follows the same pattern as open-telemetry#4128 (func_http_main): the test_*() declarations are matched by definitions in the lower half of the file (after main()). Wrapping the declarations alone would create (anonymous namespace)::test_* symbols that fail to link against the file-scope static test_*() definitions. Local verification: build of func_otlp_grpc target with WITH_OTLP_HTTP=ON + WITH_OTLP_GRPC=ON succeeded 122/122 ninja steps; --help smoke test prints usage as expected. main() and all test_*() infrastructure (declarations, the all_tests[] table, list_test_cases, run_test_case, and definitions) remain at file scope with their existing static linkage. Ratchet: * abiv1-preview warning_limit lowered from 349 to 346 * abiv2-preview warning_limit lowered from 353 to 350 Part of open-telemetry#2053 Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
marcalff
pushed a commit
that referenced
this pull request
Jun 6, 2026
…4129) Wraps the 3 file-scope class and struct declarations in functional/otlp/func_grpc_main.cc within an anonymous namespace to give them internal linkage and clear the misc-use-internal-linkage warnings clang-tidy reports on this file. The wrap covers TestResult (line 63), TestLogHandler (line 128), and test_case (line 316). It deliberately ends BEFORE the static int test_*() forward declarations at line 322+. This boundary follows the same pattern as #4128 (func_http_main): the test_*() declarations are matched by definitions in the lower half of the file (after main()). Wrapping the declarations alone would create (anonymous namespace)::test_* symbols that fail to link against the file-scope static test_*() definitions. Local verification: build of func_otlp_grpc target with WITH_OTLP_HTTP=ON + WITH_OTLP_GRPC=ON succeeded 122/122 ninja steps; --help smoke test prints usage as expected. main() and all test_*() infrastructure (declarations, the all_tests[] table, list_test_cases, run_test_case, and definitions) remain at file scope with their existing static linkage. Ratchet: * abiv1-preview warning_limit lowered from 349 to 346 * abiv2-preview warning_limit lowered from 353 to 350 Part of #2053 Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wraps the 3 file-scope class/struct declarations in
functional/otlp/func_http_main.ccwithin an anonymous namespace,clearing the misc-use-internal-linkage warnings.
6th PR of the misc-use-internal-linkage campaign (#4115, #4116, #4121,
#4122, #4124 already merged). First PR in the campaign touching the
functional/tree.Changes
functional/otlp/func_http_main.cc: insertnamespace {after thecommand-line
opt_*variables and} // namespaceafter thetest_casestruct closing brace. Wrap coversTestResult(line 62),TestLogHandler(line 145), andtest_case(line 333)..github/workflows/clang-tidy.yaml: abiv1 352 -> 349 (-3),abiv2 356 -> 353 (-3).
CHANGELOG.md: one bullet under [Unreleased].Why the wrap ends before line 339 (NOT before main())
The
static int test_*()forward declarations (lines 339-440) arematched by definitions in the lower half of the file (lines 1484-1882,
after
main()). Wrapping declarations alone would produce(anonymous namespace)::test_*symbols that do not link against thefile-scope
static int test_*()definitions.Verified locally: a wrap extending to line 453 (just before
main())produced 12+ undefined reference linker errors. The shortened wrap
ending at line 337 builds cleanly.
main()keeps external linkage. Thestatic const test_case all_tests[]table andlist_test_cases/run_test_casehelpersremain at file scope with their existing
staticlinkage.Test plan
func_otlp_http: 121/121 ninja steps(
-DWITH_OTLP_HTTP=ON -DWITH_OTLP_GRPC=OFF)func_otlp_http --helpsmoke test prints usageclang-format --dry-run --Werrorclean on the modified filePart of #2053