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

Strange warnings in Code::Blocks 17.12, GNU GCC #1192

Closed
infdivzero opened this issue Aug 13, 2018 · 12 comments
Closed

Strange warnings in Code::Blocks 17.12, GNU GCC #1192

infdivzero opened this issue Aug 13, 2018 · 12 comments
Assignees
Labels
kind: bug platform: mingw related to MinGW solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Milestone

Comments

@infdivzero
Copy link

infdivzero commented Aug 13, 2018

I'm not sure exactly what's causing it to happen but when I compile my project I often get these warnings:

||=== Build: Debug in Stellar Winds (compiler: GNU GCC Compiler) ===|
C:\C++ Projects\Stellar Winds\include\nlohmann\json.hpp||In instantiation of 'std::__cxx11::string nlohmann::detail::lexer<BasicJsonType>::get_token_string() const [with BasicJsonType = nlohmann::basic_json<>; std::__cxx11::string = std::__cxx11::basic_string<char>]':|
C:\C++ Projects\Stellar Winds\include\nlohmann\json.hpp|4309|required from 'void nlohmann::detail::parser<BasicJsonType>::parse(bool, BasicJsonType&) [with BasicJsonType = nlohmann::basic_json<>]'|
C:\C++ Projects\Stellar Winds\include\nlohmann\json.hpp|16931|required from 'static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parse(IteratorType, IteratorType, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JS|
C:\C++ Projects\Stellar Winds\include\nlohmann\json.hpp|18544|required from here|
C:\C++ Projects\Stellar Winds\include\nlohmann\json.hpp|3366|warning: unknown conversion type character 'h' in format [-Wformat=]|
C:\C++ Projects\Stellar Winds\include\nlohmann\json.hpp|3366|warning: too many arguments for format [-Wformat-extra-args]|
||=== Build finished: 0 error(s), 6 warning(s) (0 minute(s), 3 second(s)) ===|

I'm using the single header version with sfml version 2.5.0, everything else is vanilla C++.

I was able to "fix" this a few times before by removing extra includes in my classes but now it remains more constant. My project compiles and runs fine with the warnings but they're annoying and I'm not sure if they're too important. Is this normal and/or can it be fixed?

@nlohmann
Copy link
Owner

Are you using MinGW?

@infdivzero
Copy link
Author

yes

@nlohmann
Copy link
Owner

Then I guess MinGW does not implement snprintf properly.

@nlohmann nlohmann added the platform: mingw related to MinGW label Aug 14, 2018
@nlohmann
Copy link
Owner

@nlohmann
Copy link
Owner

It seems we do not need the h specified in the first place.

@nlohmann nlohmann self-assigned this Aug 14, 2018
nlohmann added a commit that referenced this issue Aug 14, 2018
@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Aug 15, 2018
@nlohmann
Copy link
Owner

Could you please check if the latest develop version fixes this issue?

@infdivzero
Copy link
Author

Yeah, sorry I forgot to check back here. I'll have a response in about 11 hours

@infdivzero
Copy link
Author

Works great, mingw builds it with no warnings/errors

@nlohmann
Copy link
Owner

Thanks for checking!

@nlohmann nlohmann added this to the Release 3.1.3 milestone Aug 17, 2018
@jacob-keller
Copy link

I'm seeing similar warnings when using MinGW again:

json.hpp:3780:105: warning: unknown conversion type character 'h' in format [-Wformat=]
(std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type));

@nlohmann
Copy link
Owner

nlohmann commented Apr 4, 2019

I'll check.

nlohmann added a commit that referenced this issue Apr 4, 2019
@nlohmann
Copy link
Owner

nlohmann commented Apr 4, 2019

@jacob-keller Could you please check whether the warning disappears in branch https://github.com/nlohmann/json/tree/issue1192?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug platform: mingw related to MinGW solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

3 participants