Skip to content
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

Visual Studio seems not to have all min() function versions #581

Closed
j-k opened this issue May 11, 2017 · 17 comments
Closed

Visual Studio seems not to have all min() function versions #581

j-k opened this issue May 11, 2017 · 17 comments
Assignees
Labels
Milestone

Comments

@j-k
Copy link

j-k commented May 11, 2017

Needed to change the line 8972 if the current version to:
std::string(start + offset, min(length, max_length - offset));
in order to make it compile

@gregmarr
Copy link
Contributor

It should still be std::min, but yeah, I don't see any reason to use the initializer_list version instead of the two parameter version here.

@nlohmann nlohmann added the platform: visual studio related to MSVC label May 11, 2017
@nlohmann nlohmann self-assigned this May 13, 2017
@nlohmann
Copy link
Owner

I did not know that MSVC does not support the initializer-list version - according to cppreference it is C++11. Anyway, I shall replace it with the other version.

nlohmann added a commit that referenced this issue May 13, 2017
@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label May 13, 2017
@nlohmann
Copy link
Owner

@j-k Could you please check if the fix works for you?

@gregmarr
Copy link
Contributor

I didn't know that it wouldn't support it either until this issue was posted. :)

@guygee
Copy link

guygee commented May 31, 2017

cloned today, had the same issue, the suggested fix in the first post worked.
VS2015 community V. 14.0.25420.1 compiling x86

@nlohmann
Copy link
Owner

Thanks!

@nlohmann nlohmann removed the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label May 31, 2017
@nlohmann nlohmann added this to the Release 3.0.0 milestone May 31, 2017
@guygee
Copy link

guygee commented May 31, 2017

I should have added the error msgs and line number:
Error C2589 '(': illegal token on right side of '::' [...]\json.hpp 8936
Error C2059 syntax error: '::' LibSonarProc [...]\json.hpp 8936
it compiled for me when I changed std::min ->min
Wish I was using g++

@nlohmann
Copy link
Owner

I don't understand: I fixed this with commit 9b764ee. Does it still not work?

@guygee
Copy link

guygee commented Jun 1, 2017

Line 8936:
return std::string(start + offset, std::min(length, max_length - offset));
This fails to compile in VS2015 with the errors I show above.
If I change to this, it will compile:
return std::string(start + offset, min(length, max_length - offset));

@nlohmann
Copy link
Owner

nlohmann commented Jun 1, 2017

Which version of MSVC is this?

@guygee
Copy link

guygee commented Jun 4, 2017

C:\Program Files (x86)\Microsoft Visual Studio 14.0>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

@nlohmann
Copy link
Owner

nlohmann commented Jun 4, 2017

This version is not supported, see https://github.com/nlohmann/json#supported-compilers.

@guygee
Copy link

guygee commented Jun 4, 2017

OK, thank you.

@nlohmann
Copy link
Owner

nlohmann commented Jun 4, 2017

No worries. :)

@guygee
Copy link

guygee commented Jun 4, 2017

Just to be clear,
Version 19.00.24210 is the MS command-line compiler version,
as I posted above, the Visual Studio version is 2015, V. 14.0.25420.1

@nlohmann
Copy link
Owner

nlohmann commented Jun 4, 2017

This is strange - this version is supported. But AppVeyor has no issues building and executing the tests.

@nlohmann
Copy link
Owner

nlohmann commented Jun 5, 2017

I had another look: AppVeyor compiles the code without issues with Microsoft (R) Build Engine version 14.0.25420.1: https://ci.appveyor.com/project/nlohmann/json/build/job/74yfdd5tjwk0i7s1

Maybe this is related: #603

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants