[BUILD] Suppress deprecated warnings in generated semconv metric headers#4088
Conversation
|
|
| # define OPENTELEMETRY_SUPPRESS_DEPRECATED_END _Pragma("GCC diagnostic pop") | ||
| #elif defined(_MSC_VER) | ||
| # define OPENTELEMETRY_SUPPRESS_DEPRECATED_BEGIN \ | ||
| __pragma(warning(push)) __pragma(warning(disable : 4996)) |
There was a problem hiding this comment.
Optional nit: if clang-format allows it, could we keep one pragma per macro line for readability in the GCC and MSVC branches, similar to the Clang branch? The current formatting is correct, but th push/disable sequence is a little harder to scan when it gets collapsed onto one line.
There was a problem hiding this comment.
Thanks for taking a look :)
Good idea, updated to make it a bit more readable. Had to wrap the block in clang-format off because the formatting rules collapse anything under the 100-col limit onto one line.
Can go back to previous formatting if we don't want to use clang-format off here.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4088 +/- ##
=======================================
Coverage 82.00% 82.00%
=======================================
Files 385 385
Lines 16030 16030
=======================================
Hits 13143 13143
Misses 2887 2887 🚀 New features to boost your workflow:
|
marcalff
left a comment
There was a problem hiding this comment.
LGTM.
Nicely done, this will suppress a lot of noise.
Fixes #3986
Changes
Attempting fix for issue 3986, deprecation warnings reported from metrics_foo_library example.
When some of the semconv generated headers are included, deprecated warnings for functions are produced even if the function is not used. This occurs because the function uses deprecated variables in its body. That's triggers
-Wdeprecated-declarationsand since these helpers arestatic inlinein a header, every file that includes the header gets the warning. This PR proposes adding new macros,OPENTELEMETRY_SUPPRESS_DEPRECATED_BEGINandOPENTELEMETRY_SUPPRESS_DEPRECATED_ENDto manually wrap these deprecated variables in the generator.Appreciate time and effort for review. Happy to discuss / update to a more approriate solution.
Thank you :)
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes