Skip to content

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

Description

@dariost

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

Activity

  1. self-assigned this
    on Aug 18, 2015
  2. michalplucinski commented on Nov 12, 2015

    @michalplucinski

    Any status report on this bug?

  3. nlohmann commented on Dec 7, 2015

    @nlohmann
    Owner

    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 :-(

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions