nlohmann / json

JSON for Modern C++
https://json.nlohmann.me
MIT License
41.3k stars 6.58k forks source link

Issue with including <version> #4241

Closed oleg-alexandrov closed 6 months ago

oleg-alexandrov commented 6 months ago

Description

I ran into a compilation problem for some software using this library which was triggered by this line:

https://github.com/nlohmann/json/blob/3780b41dd070436f3f55327b0a88f27a52e2dfa8/include/nlohmann/detail/macro_scope.hpp#L52C18-L52C18

which says: #include

It was including some unrelated file. I guess both that package and json itself were using "version" for their own thing. This software should search instead "json_version" or something, and that other package should have its own convention, I guess.

Reproduction steps

At the base of a conda environment create a file called "version". Then this library will try to include it and will fail. This may require setting some compiler include flags. The point here that it is fragile logic to count on a file called "version" to be the thing one thinks of as "version".

Expected vs. actual results

I expected json to compile, but it failed.

Minimal code example

No response

Error messages

No response

Compiler and operating system

Linux

Library version

3.11.2

Validation

gregmarr commented 6 months ago

The <version> header is part of standard C++, so it's the other library that will need to be fixed. https://en.cppreference.com/w/cpp/header/version

oleg-alexandrov commented 6 months ago

Can't argue with the standard library, I guess. Thank you. I will close this.