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

Compile error with g++ 4.9.3 cygwin 64-bit #112

Closed
dariost opened this issue Aug 17, 2015 · 2 comments
Closed

Compile error with g++ 4.9.3 cygwin 64-bit #112

dariost opened this issue Aug 17, 2015 · 2 comments
Assignees

Comments

@dariost
Copy link

dariost commented Aug 17, 2015

I've tried to compile the following code

#include "json.hpp"
#include <iostream>

using json = nlohmann::json;

int main()
{
    json j;
    j["success"] = false;
    std::cout << j.dump(4) << std::endl;
    return 0;
}

with g++ 4.9.3 on cygwin 64-bit (I'm using Windows 10)

$ g++ --version
g++ (GCC) 4.9.3
Copyright (C) 2015 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.

This is the compiler output

$ g++ main.cpp -std=c++11 -o main
In file included from main.cpp:1:0:
json.hpp: In member function ‘std::string nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType>::iterator_wrapper::iterator_wrapper_internal::calculate_key()’:
json.hpp:5725:32: error: ‘to_string’ is not a member of ‘std’
                         return std::to_string(array_index);
                                ^
json.hpp: In member function ‘long double nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType>::lexer::get_number() const’:
json.hpp:6940:36: error: ‘strtold’ is not a member of ‘std’
             const auto float_val = std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start),
                                    ^
json.hpp:6940:36: note: suggested alternative:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/c++/cstdlib:72:0,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/c++/bits/stl_algo.h:59,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/c++/algorithm:62,
                 from json.hpp:41,
                 from main.cpp:1:
/usr/include/stdlib.h:279:20: note:   ‘strtold’
 extern long double strtold (const char *__restrict, char **__restrict);
@nlohmann nlohmann self-assigned this Aug 18, 2015
@michalplucinski
Copy link

Any status report on this bug?

@nlohmann
Copy link
Owner

nlohmann commented Dec 7, 2015

This seems to be an issue with cygwin's GCC, and unfortunately even GCC 5.2 does not fix it: http://stackoverflow.com/questions/33500074/cygwin-g-5-2-to-string-is-not-a-member-of-std :-(

@nlohmann nlohmann closed this as completed Dec 7, 2015
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

3 participants