-
Notifications
You must be signed in to change notification settings - Fork 440
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
Resolve NOMINMAX issues where possible #481
Conversation
# ifndef NOMINMAX | ||
# define NOMINMAX | ||
# endif | ||
# include <Windows.h> |
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.
EDIT, sorry for the wrong paste. I was asking how could if the user could include windows.h
before include our header file.
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.
Sorry Tom, what do you mean by C:\GH\otcpp\ext\include\opentelemetry\ext\http\client\curl\http_operation_curl.h(208)
?
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.
Reason why I'm adding this is that Josh would need this in his PR that is failing. Related PR: #443
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.
if the user could include windows.h before include our header file
Yeah, then it will break for those users. We most likely need to add some blurb in our documentation, that since our SDK uses range limits extensively in public API, that means we should tell users that they must revisit their usage of min
and max
macros, to make sure we are not breaking them on Windows..
Basically then the user should add the NOMINMAX define on their end ..
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.
I tried fixing this where possible. But there are some spots, where our SDK defines class methods called min
and max
- that will surely break if our Windows customers don't define NOMINMAX
themselves for their project.
Codecov Report
@@ Coverage Diff @@
## master #481 +/- ##
==========================================
+ Coverage 94.36% 94.38% +0.02%
==========================================
Files 189 189
Lines 8410 8410
==========================================
+ Hits 7936 7938 +2
+ Misses 474 472 -2
|
The issue is that
Windows.h
redefines bothmin
andmax
as macros.There are several fixes possible:
std::min
andstd::max
with parenthesis; ORNOMINMAX
for the entire project in CMake; ORstd::*
is going to be used,#define NOMINMAX
right before the inclusion of Windows.hSince there were two recent hits @mishal23 @jsuereth , I'm applying targeted fix to avoid this issue wherever possible.
Not defining
NOMINMAX
globally, as this may lead to other interesting side-effects inside the bowels of Windows SDK 😁