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

MinGW have no std::to_string #80

Closed
Ingener74 opened this issue Jun 3, 2015 · 9 comments
Closed

MinGW have no std::to_string #80

Ingener74 opened this issue Jun 3, 2015 · 9 comments

Comments

@Ingener74
Copy link

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

@nlohmann
Copy link
Owner

nlohmann commented Jun 3, 2015

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?

@nlohmann nlohmann self-assigned this Jun 3, 2015
@Ingener74
Copy link
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 :)

@nlohmann
Copy link
Owner

nlohmann commented Jun 4, 2015

Could you please try whether it works now?

@Ingener74
Copy link
Author

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

@nlohmann
Copy link
Owner

nlohmann commented Jun 4, 2015

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

@Ingener74
Copy link
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

@Ingener74
Copy link
Author

if delete

using std::snprintf;

compiles and works fine

nlohmann added a commit that referenced this issue Jun 4, 2015
@nlohmann
Copy link
Owner

nlohmann commented Jun 4, 2015

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

Ingener74 added a commit to Ingener74/json that referenced this issue Jun 4, 2015
@Ingener74
Copy link
Author

Thank you. It helped :)

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

No branches or pull requests

2 participants