-
Notifications
You must be signed in to change notification settings - Fork 69
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
Defines min and max macros on Windows #37
Comments
You should probably report that issue to the https://github.com/boostorg/winapi module to get the fix for all the Boost libraries that use it, rather than just for the Stacktrace library. P.S.: It includes |
Boost.WinAPI cannot define The right way to deal with
When defining
I think, we had these tricks in our guidelines somewhere, but I can't find now. |
After looking into this in more detail, it looks like the problem does actually lie with the stacktrace module after all (the winapi module is performing as expected). When including Therefore, I would propose the following fix:
|
As an example, when not using the boost stacktrace module, the following minimal code compiles OK and correctly prints
However, including the boost stacktrace module (
Adding the fix described in the previous comment to In cases where the user is already using the
I will admit that this does depend on the order of the includes (the stacktrace module must be included after
However, this should be the much rarer, and easier to document case, as opposed to the current situation. Also note that I'm not particularly attached to the exact implementation of the proposed fix, I'm just using it as an example :) Is this something that would be worth submitting a PR for? |
@peetw IMHO, if you're having the problem with |
@Lastique It looks like we're going to have to agree to disagree on that - personally I don't think third-party libraries should re-define standard library functions by default. I know I can work around it (and I currently do, by placing def/undef Finally, don't get me wrong, I am very grateful for the work you guys have put in to get this released - getting stacktraces in C++ on Windows was always a pain, so thank you! :) |
Essentially, the stacktrace module (eventually) includes the
windows.h
header, which then defines macros for min and max, which then conflict with thestd::min()
,std::min()
andstd::numeric_limits<T>::min/max()
functions, resulting in compilation errors.This issue was also observed/fixed for the ASIO module: https://svn.boost.org/trac10/ticket/3901
A workaround for now is to just
#define NOMINMAX
when building the project, however it would be much better if the stacktrace module defined this itself. Perhaps this could be defined in a newdetail/config.hpp
file (similarly to ASIO)?The text was updated successfully, but these errors were encountered: