Skip to content

MinGW have no std::to_string #80

Closed

Description

@Ingener74

c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:2015:24: error: 'to_string' is not a member of 'std'

please use somethink like that:
template
std::string to_string(T t){
std::stringstream s;
s << t;
return s.str();
}

sorry. my english is bad

Activity

  1. nlohmann commented on Jun 3, 2015

    @nlohmann
    Owner

    Thanks for reporting! Does the rest of the code compile? I am asking, because I do not want to add changes, before knowing that MinGW can work in principle. Furthermore, what version of MinGW and compiler do you use?

  2. self-assigned this
    on Jun 3, 2015
  3. Ingener74 commented on Jun 3, 2015

    @Ingener74
    Author

    bash-3.1$ g++.exe --version
    g++.exe (GCC) 4.8.1
    Copyright (C) 2013 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    i am compile with -std=c++11 option

    and i have another some errors with MinGW
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp: In member function 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator>::dump(bool, unsigned int, unsigned int) const':
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:2015:24: error: 'to_string' is not a member of 'std'
    return std::to_string(m_value.number_integer);
    ^
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:2022:59: error: 'snprintf' is not a member of 'std'
    const auto sz = static_cast(std::snprintf(nullptr, 0, "%.15g", m_value.number_float));
    ^
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:2022:59: note: suggested alternative:
    In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\cstdio:42:0,
    from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\random:39,
    from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h:65,
    from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\algorithm:62,
    from c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:33,
    from c:/Users/Pavel/workspace/Jupiter/modules/Jupiter/src/ComplexShape.cpp:10:
    c:\mingw\include\stdio.h:330:29: note: 'snprintf'
    int __cdecl __MINGW_NOTHROW snprintf (char *, size_t, const char *, ...);
    ^
    In file included from c:/Users/Pavel/workspace/Jupiter/modules/Jupiter/src/ComplexShape.cpp:10:0:
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:2024:17: error: 'snprintf' is not a member of 'std'
    std::snprintf(&buf[0], buf.size(), "%.15g", m_value.number_float);
    ^
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:2024:17: note: suggested alternative:
    In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\cstdio:42:0,
    from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\random:39,
    from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h:65,
    from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\algorithm:62,
    from c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:33,
    from c:/Users/Pavel/workspace/Jupiter/modules/Jupiter/src/ComplexShape.cpp:10:
    c:\mingw\include\stdio.h:330:29: note: 'snprintf'
    int __cdecl __MINGW_NOTHROW snprintf (char *, size_t, const char *, ...);
    ^
    In file included from c:/Users/Pavel/workspace/Jupiter/modules/Jupiter/src/ComplexShape.cpp:10:0:
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp: In member function 'void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator>::lexer::yyfill()':
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:4123:19: error: 'ssize_t' does not name a type
    const ssize_t offset_start = m_start - m_content;
    ^
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:4124:19: error: 'ssize_t' does not name a type
    const ssize_t offset_marker = m_marker - m_start;
    ^
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:4125:19: error: 'ssize_t' does not name a type
    const ssize_t offset_cursor = m_cursor - m_start;
    ^
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:4127:51: error: 'offset_start' was not declared in this scope
    m_buffer.erase(0, static_cast<size_t>(offset_start));
    ^
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:4134:34: error: 'offset_marker' was not declared in this scope
    m_marker = m_start + offset_marker;
    ^
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:4135:34: error: 'offset_cursor' was not declared in this scope
    m_cursor = m_start + offset_cursor;
    ^
    Thank's for your quick answer :)

  4. added a commit that references this issue on Jun 4, 2015
  5. nlohmann commented on Jun 4, 2015

    @nlohmann
    Owner

    Could you please try whether it works now?

  6. Ingener74 commented on Jun 4, 2015

    @Ingener74
    Author

    Ok. Thank's. I'll try at home a couple of hours.

  7. nlohmann commented on Jun 4, 2015

    @nlohmann
    Owner

    I could compile it with i586-mingw32-g++ (GCC) 4.8.0 for OS X (from http://crossgcc.rts-software.org/doku.php?id=compiling_for_win32).

  8. Ingener74 commented on Jun 4, 2015

    @Ingener74
    Author

    i try and get error

    �[0m[ 56%] �[32mBuilding CXX object modules/Jupiter/CMakeFiles/Jupiter.dir/src/ComplexShape.cpp.obj
    In file included from c:/Users/Pavel/workspace/Jupiter/modules/Jupiter/src/ComplexShape.cpp:11:0:
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp: In member function 'void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType>::dump(std::ostream&, bool, unsigned int, unsigned int) const':
    c:/Users/Pavel/workspace/Jupiter/3rdparty/json/src/json.hpp:2287:28: error: 'std::snprintf' has not been declared
                     using std::snprintf;
                                ^
    make[2]: *** [modules/Jupiter/CMakeFiles/Jupiter.dir/src/ComplexShape.cpp.obj] Error 1
    make[1]: *** [modules/Jupiter/CMakeFiles/Jupiter.dir/all] Error 2
    make: *** [all] Error 2
    �[0m
    
  9. Ingener74 commented on Jun 4, 2015

    @Ingener74
    Author

    if delete

    using std::snprintf;
    

    compiles and works fine

  10. added a commit that references this issue on Jun 4, 2015
  11. nlohmann commented on Jun 4, 2015

    @nlohmann
    Owner

    I adjusted the code in the last commit. I should compile now with MinGW.

  12. added a commit that references this issue on Jun 4, 2015
  13. Ingener74 commented on Jun 4, 2015

    @Ingener74
    Author

    Thank you. It helped :)

  14. added a commit that references this issue on Nov 13, 2025
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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions