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

Compilation error due to assuming that private=public #43

Closed
gnzlbg opened this issue Mar 4, 2015 · 1 comment · Fixed by #2352
Closed

Compilation error due to assuming that private=public #43

gnzlbg opened this issue Mar 4, 2015 · 1 comment · Fixed by #2352
Assignees
Labels
kind: bug release item: 🔨 further change solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@gnzlbg
Copy link

gnzlbg commented Mar 4, 2015

The snippet to reproduce the error:

  struct A {
    nlohmann::json j;
    auto has_entry(std::string n) {
      return j.find(n) != j.end() ? true : false;
    }
  };

what the error looks like:

src/json.hpp:1073:20: error: 'm_it' is a private member of 'nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long,
      double, std::allocator>::const_iterator'
            result.m_it.object_iterator = m_value.object->find(key);
                   ^

This is not catched by the unit tests because they are compiled by defining private=public.

A "better" way to do that could be to have a separate file only for those tests that "need" private=public.

This might be clang 3.6 specific, since I'm the only one who seems to be having problems.

I worked around this issue by including the library as follows:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wfloat-equal"
#pragma clang diagnostic ignored "-Wdeprecated"
#define private public
#include <json.hpp>
#define private private
#pragma clang diagnostic pop
@nlohmann
Copy link
Owner

nlohmann commented Mar 6, 2015

Dear @gnzlbg,

thanks for reporting! It sure looks like a bug. I shall have a look once I'm back from holidays.

All the best
Niels

@nlohmann nlohmann self-assigned this Mar 22, 2015
@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Aug 12, 2020
@nlohmann nlohmann added this to the Release 3.9.2 milestone Aug 12, 2020
GerHobbelt pushed a commit to GerHobbelt/nlohmann-json that referenced this issue May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug release item: 🔨 further change solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants