Comments (4)
This seems to require the NOMINMAX preprocessor definition. I'd suggest adding that with the check for if its already defined before wherever windows.h is included, if in fact it is included.
Perhaps it isn't in the GIL library and its just my large project, but I'm running into issues when I need both this to compile and code using the standard MAX macro.
Edit:
Adding this link to a separate issue where the same problem I'm trying to describe is brought up: boostorg/stacktrace#76
from gil.
This seems to require the NOMINMAX preprocessor definition
Yes, Windows SDK/MSVC, in many, if not most uses of std::numeric_limits<T>::max()
will either require to #define NOMINMAX
or function-like macro suppression with extra parentheses (std::numeric_limits<T>::max)()
or one of several other possible tricks to work around the Windows SDK/MSVC annoyance.
I'd suggest adding that with the check for if its already defined before wherever
windows.h
is included, if in fact it is included.
AFAICT, nowhere in GIL the windows.h
is included. However, to ensure building tests/examples is not prone to this annoyance, we #define NOMINMAX
in the build configurations:
Line 41 in c3e84ad
Line 88 in c3e84ad
IMO, it is not GIL or Boost or other C++ library duty but a library's user duty to #define NOMINMAX
before any Windows header, as suggested by LLVM/clang/libcxx infrastructure:
#ifdef min
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
#if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX "
"before any Windows header. #undefing min")
#else
#warning: macro min is incompatible with C++. #undefing min
#endif
#endif
#undef min
#endif
Alternatively, we may consider adding very similar check and warning somewhere in boost/gil.hpp
. What do you think, @stefanseefeld ?
from gil.
Thanks for getting back to me so quickly. I agree with your opinion that it is on the library user to handle this, I'll look into defining NOMINMAX for my project. I was doing so until I came across an error where we're using what I think is a standard definition of max, in another library, that won't compile with NOMINMAX defined. So feels like a catch 22 between using GIL and this other library.
We're using Boost-gil 1.70 from Vcpkg by the way. My vote would be for the "function-like macro suppression with extra parenthesis" but in the meantime I'll try to find all the Windows headers and define NOMINMAX before including them.
Thanks,
Tyler
from gil.
My vote would be for the "function-like macro suppression with extra parenthesis"
I've searched through the code and apparently GIL already uses this technique in numerous places, e.g.
gil/include/boost/gil/color_convert.hpp
Lines 147 to 148 in c3e84ad
as well as explicit template parameter to suppress the macro:
gil/include/boost/gil/algorithm.hpp
Line 975 in c3e84ad
Please, consider contributing a pull request with similar fixes that will help your project.
Since such technique is already in use, I don't see any reason why we shouldn't accept it.
from gil.
Related Issues (20)
- Fix wrong pixel channel truncation in binary threshold and truncate threshold HOT 2
- Consider moving channel_convert_to_unsigned out of detail namespace
- color_convert_hsl / gcc-5~c++14: converting to std::tuple from initializer list would use explicit constructor constexpr std::tuple
- color_convert_rgb / gcc-5~c++14: converting to std::tuple from initializer list would use explicit constructor constexpr std::tuple
- color_convert_hsl.cpp and color_convert_rgb.cpp error: no matching constructor for initialization of std::vector<color_t>
- Allow implicit conversion from gray8_ptr_t to gray8_step_ptr_t HOT 3
- g++ 12.1.1 fails to compile Boost.GIL with -std=c++20 HOT 3
- unsued variable warning
- Convolution2d seems to be not correct. HOT 1
- stream device "tell" method absent! HOT 2
- Support for reading/writing 1 bit (black/white) BMP images? HOT 2
- Alpha-blending HOT 4
- Overflow in channel convertion HOT 2
- heap-buffer-overflow when using io-related functions HOT 1
- Running the convolve_2d.cpp test causes an alignment error on ARM
- About Enterprise Managed Users - GitHub Enterprise Cloud Docs
- https://docs.github.com/es/[email protected]/admin/monitoring-managing-and-updating-your-instance/updating-the-virtual-machine-and-physical-resources/upgrading-github-enterprise-server HOT 1
- CMake: Dependency on Boost::filesystem is wrong HOT 5
- Use of min and max in Gil conflicts with Win32-API on Windows/MSVC HOT 4
- Prepare for release with Boost 1.86 HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gil.