jarro2783 / cxxopts

Lightweight C++ command line option parser
MIT License
4.17k stars 582 forks source link

When using Chinese Debug mode in Visual Studio, the assertion fails in std::isblank #364

Closed 66maer closed 2 years ago

66maer commented 2 years ago

image

image

extern "C" int __cdecl _chvalidator(int const c, int const mask)
{
    _ASSERTE(c >= -1 && c <= 255);
    return _chvalidator_l(nullptr, c, mask);
}
jarro2783 commented 2 years ago

Fixed by #365

hillmich commented 2 years ago

The corresponding PR #365 to this issue breaks the build on our CI on MacOS (see corresponding run on cda-tum/ddsim#123, error also stated below). It seems to me this is not caused by our code. Would you be wiling to have a look?

...
In file included from /Users/runner/work/ddsim/ddsim/apps/simple.cpp:10:
/Users/runner/work/ddsim/ddsim/extern/cxxopts/include/cxxopts.hpp:2093:33: error: too many arguments to function call, expected single argument '_c', have 2 arguments
    if (std::isblank(*previous, std::locale::classic()))
        ~~~~~~~~~~~~            ^~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/_ctype.h:224:1: note: 'isblank' declared here
isblank(int _c)
^
In file included from /Users/runner/work/ddsim/ddsim/apps/simple.cpp:10:
/Users/runner/work/ddsim/ddsim/extern/cxxopts/include/cxxopts.hpp:2098:33: error: too many arguments to function call, expected single argument '_c', have 2 arguments
    if (!std::isblank(*current, std::locale::classic()))
         ~~~~~~~~~~~~           ^~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/_ctype.h:224:1: note: 'isblank' declared here
isblank(int _c)
^
2 errors generated.
jarro2783 commented 2 years ago

According to https://en.cppreference.com/w/cpp/locale/isblank that function is supported by C++11. Is this a recent compiler? It might need an exception for your compiler if it doesn't support that function signature.

hillmich commented 2 years ago

The mentioned overload of isblank is from a header that's not included in cxxopts.hpp. I hope you don't mind that I created #368 :)