Comments (11)
I usually define NOMINMAX
as preprocessor def in VS
from cxxopts.
Which version of the compiler? I've had a few other people discuss MSVC and they haven't had issues.
Does it also work if you add an extra set of parentheses around the argument to min and max?
from cxxopts.
extra parentheses doesn't solve the problem,
VC toolchain is version 15, aka VisualStudio 2017
this is a known issue, see here or here
the description in MSDN here
from cxxopts.
I'm happy to accept a pull request. I wonder if a better option would be to write (std::max)(x, y)
as suggested by the StackOverflow answers, rather than #undef
.
from cxxopts.
sure, Ill perform a few tests with both variants and raise a request
from cxxopts.
Is this still an issue for you?
from cxxopts.
from cxxopts.
I just picked this up for a project on Windows. Definitely use the built-in NOMINMAX
define for Windows.h
instead of trying to undef it manually.
If you undef, #include <cxxopts.hpp>
would have side-effects for applications assuming that min and max are existing macros in later code, since the preprocessor has no scope.
Proper usage:
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <Windows.h>
#include <cxxopts.hpp>
An example that would break with #undef
:
#include <Windows.h>
#include <cxxopts.hpp>
int main (int argc, char* argv[]) {
return max(2, 3);
}
from cxxopts.
agreed ,NOMINMAX prefered way and it works fine for me too
request can be closed without modification the library
from cxxopts.
@jarro2783 I am sorry to bother the rest of others about a closed issue. As someone who tries to use cxxopts
on windows with MSVC, I found it is very frustrated to deal with MACRO min/max under WINDOWS
. I should blame that MSVC introduce such an annoying feature that affects extensively. But I would sugguest that opensource library should provide more friendly solution to third party users. As an example, add parenthesis to anywhere you have min
and max
as it is suggested by NIRO
(std::numeric_limits<size_type>::max)()
(std::min)
(std::max)
As it is said,
No need for the NOMINMAX macro in this case, plus you won't get compiler warnings
I wrote this in memory of my lost 30 minutes at this time.
from cxxopts.
That seems like a reasonable workaround. I'll make the changes at some point soonish.
from cxxopts.
Related Issues (20)
- Branch Name: main HOT 1
- About a new tag-release HOT 1
- feature request/question: support the one dash as argument HOT 2
- Feature request: value pairs or tuples HOT 1
- Renaming of OptionException should be mentioned in changelog HOT 1
- Allow "G", "M" and 'k' when parsing arguments HOT 2
- Getting a sign-conversion warning/error with clang 14 and CXXOPTS_USE_UNICODE_HELP ON HOT 2
- A proposition to implement any complex rule on the arguments
- unannotated fall-through between switch labels HOT 3
- Are unrecognized options supported? HOT 1
- std::bad_alloc during dlopen on integer_pattern initialization HOT 4
- In Linux systems, the tilde symbol (~) cannot be automatically expanded to "/home/user1," HOT 4
- -option Error message. I think we should not just report command ‘p’ error. HOT 5
- Report a typo in README.md doc(in master branch) HOT 1
- What is the use of constructor parameters in options("MyProgram", "One line description of MyProgram")? HOT 3
- Filtered argc/argv HOT 3
- cxxopts-3.2.0 breaks in c++20 mode: invalid operands to binary expression ('std::stringstream' (aka 'basic_stringstream<char>') and 'std::optional<bool>' HOT 8
- Add + as an argument indicator
- short arg unable to accept argument.
- Sub-options support HOT 1
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 cxxopts.