-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make macros.h available for all source files via version.h #1918
Make macros.h available for all source files via version.h #1918
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1918 +/- ##
=======================================
Coverage 86.92% 86.92%
=======================================
Files 165 165
Lines 4594 4594
=======================================
Hits 3993 3993
Misses 601 601
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this change will expose:
- the
cstdint
header file - the
regex
headerfile - the
HAVE_WORKING_REGEX
symbol, which is not using anOPENTELEMETRY_
prefix and therefore pollutes the build
for any user of any api header file.
I would prefer to apply the include-what-you-use principles, and only include macro.h in the few places where it is needed.
The API header files are stable by now, so there is no real maintenance burden and breaks caused by missing includes on macro.h
What is the motivation or rationale for this change ?
Perhaps we should remove cstdint from macro here? The intention was the make the all the generic macros in a common header file for all source files. I am adding some declspec macro for building DLL, so I'd like to avoid including it for every header (there could be many of them). |
Perhaps move |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the following changes, please consider to:
- rename HAVE_WORKING_REGEX to OPENTELEMETRY_HAVE_WORKING_REGEX, everywhere (including in the SDK)
- only set OPENTELEMETRY_HAVE_WORKING_REGEX based on the GCC version, but do not include regex.h when setting the flag
- include (conditionally) regex.h when using the flag
- remove the code duplication from trace_state.h
With this, all uses should look like:
#if OPENTELEMETRY_HAVE_WORKING_REGEX
# include <regex>
#endif
I know this is an existing issue, but cleaning it up before exposing macro.h is needed, to avoid causing side effects on user code.
No strong opinion on whether to put the code to set OPENTELEMETRY_HAVE_WORKING_REGEX in macro.h or config.h
Thanks for the fix.
Good idea, see my latest review comments. |
Changes
As the macros defined in
macros.h
is general for all sources, including it inversion.h
to make it available for all sources (no need for separate#include "opentelemetry/common/macros.h"
statement.For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes