Skip to content

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

Closed

Description

@j-k

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

Activity

  1. gregmarr commented on May 11, 2017

    @gregmarr
    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.

  2. self-assigned this
    on May 13, 2017
  3. nlohmann commented on May 13, 2017

    @nlohmann
    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.

  4. added a commit that references this issue on May 13, 2017
  5. nlohmann commented on May 13, 2017

    @nlohmann
    Owner

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

  6. gregmarr commented on May 14, 2017

    @gregmarr
    Contributor

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

  7. guygee commented on May 31, 2017

    @guygee

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

  8. nlohmann commented on May 31, 2017

    @nlohmann
    Owner

    Thanks!

  9. removed
    solution: proposed fixa fix for the issue has been proposed and waits for confirmation
    on May 31, 2017
  10. added this to the Release 3.0.0 milestone on May 31, 2017
  11. guygee commented on May 31, 2017

    @guygee

    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++

  12. nlohmann commented on May 31, 2017

    @nlohmann
    Owner

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

  13. guygee commented on Jun 1, 2017

    @guygee

    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));

  14. nlohmann commented on Jun 1, 2017

    @nlohmann
    Owner

    Which version of MSVC is this?

  15. guygee commented on Jun 4, 2017

    @guygee

    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.

  16. nlohmann commented on Jun 4, 2017

    @nlohmann
    Owner

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

  17. guygee commented on Jun 4, 2017

    @guygee

    OK, thank you.

  18. nlohmann commented on Jun 4, 2017

    @nlohmann
    Owner

    No worries. :)

  19. guygee commented on Jun 4, 2017

    @guygee

    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

  20. nlohmann commented on Jun 4, 2017

    @nlohmann
    Owner

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

  21. nlohmann commented on Jun 5, 2017

    @nlohmann
    Owner

    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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions