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 issues when included in project #2094

Closed
prithvisb opened this issue May 8, 2020 · 5 comments
Closed

Compilation issues when included in project #2094

prithvisb opened this issue May 8, 2020 · 5 comments
Labels
kind: bug state: needs more info the author of the issue needs to provide more details

Comments

@prithvisb
Copy link

prithvisb commented May 8, 2020

  • What is the issue you have?
    When I include the file "json.hpp" in my source code I get the following error(s)

/inc/json.hpp:32:35: error: stray '\302' in program

<title>json/json.hpp at develop · nlohmann/json · GitHub</title> \ inc/json.hpp:360:76: error: stray '\206' in program \ inc/json.hpp:1067:70: error: stray '#' in program #define NLOHMANN_JSON_VERSION_PATCH 3

"json.hpp:33275:189: error: expected unqualified-id before '<' token
#include <vector> // vector"

<this follows for virtually every line of the header>

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

#include "json.hpp"

<my code that does not use any json features yet>

  • What is the expected behavior?

That the code should compile

  • And what is the actual behavior instead?
    Several pages of compile errors

  • Which compiler and operating system are you using? Is it a supported compiler?
    -- The C compiler identification is GNU 8.3.1
    -- The CXX compiler identification is GNU 8.3.1
    OS - macos but the compilation is happening while building a centos 7 docker image.

I use Cmake and have SET(CMAKE_CXX_STANDARD 17)

  • Did you use a released version of the library or the version from the develop branch?
    Release
@nlohmann
Copy link
Owner

nlohmann commented May 9, 2020

Can you make sure the file is exactly the one from the release? It seems that the stray may have been introduced by copy/pasting (see https://arduino.stackexchange.com/questions/30581/stray-302-in-program-error-when-compiling for example). Can you attach the json.hpp you are using?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label May 9, 2020
@prithvisb
Copy link
Author

I think that's probably it. The errors don't correspond to the line numbers in any meaningful way. I copied the file directly from the include.zip file and still have the same issue. I'm looking online if this is a macos problem but I don't understand why copying the file directly is not helping.

Is there an encoding issue in the source? I tried saving in vi with :set nobomb, I opened and saved the file in xcode
json.hpp.zip

I've attached what I'm currently using.

@nlohmann
Copy link
Owner

I am using macOS myself and never had such problems. I could also see no encoding issue in the attached file. If there was a BOM, then the error should be directly in the first characters. Very strange issue.

@prithvisb
Copy link
Author

I'm closing this issue. I did a split diff of the file and found a lot of weird characters. Very long story short I had a process that was trampling on json.hpp in the background. I killed that process and re-downloaded your file and everything works. User error. Sorry for the trouble and thanks for the help!

@felixcrazzolara
Copy link

I had a similar issue when I downloaded the header file with wget. Copying the file out of the zip folder instead, solved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug state: needs more info the author of the issue needs to provide more details
Projects
None yet
Development

No branches or pull requests

3 participants