Skip to content

general compile error and warning fixes #492

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

Closed
wants to merge 1 commit into from

Conversation

zeromus
Copy link

@zeromus zeromus commented Jun 28, 2016

. fix a bunch of missing string and stdio headers (really weird that these crept into the code...?)
. typo amalgated -> amalgamated
. add #if JSON_USE_EXCEPTION guard around exception-throwing code
. change format string "%%.%dg" to "%%.%ug" for an unsigned int

. typo amalgated -> amalgamated
. add #if JSON_USE_EXCEPTION guard around exception-throwing code
. change format string "%%.%dg" to "%%.%ug" for an unsigned int
@@ -18,6 +18,8 @@
#include <memory>
#include <set>
#include <limits>
#include <stdio.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimally, wouldn't these have to be cstring and cstdio for strict compatibility with modern compilers?

Adding headers is fine. But could you tell us where this was failing to compile?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beats me. I dont use modern compilers or know anything about them. This was failing on visual c++ 2010.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we can continue to support VS2010 for the master branch. 0.y.z will work fine.

But could you try #include <cstdio> and #include <cstring> in VS2010, and if it works, push that to this branch to update this pull-request?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh sorry I was mistaken. It wasn't VS2010, it was a ghetto version of ARMCC I have to use. Each of the files I added stdio.h or string.h to already had <cstring> and<cstdio> in it, and it wasn't sufficient--so your test is already done.

I noticed this snippet in one place (and snippets like it in many other places)

#if defined(__QNXNTO__)
#define sscanf std::sscanf
#endif`

This is representative of another solution to the actual problem I had (symbols like sscanf being undeclared, being in the std:: namespace instead). So, it seems you've dealt with this problem before.

Since I don't know anything about compilers from the present or the future (it's all the same to a guy stuck in the past) all I can do is naively google up things like http://en.cppreference.com/w/cpp/io/c/sscanf which seems to say those functions belong in std:: namespace indeed and assume your great modern compilers which support them without the std:: qualifier are leading you astray

I'll let you think on this a while before I do any reverting. I can't competently suggest anything, but can incompetently suggest you sprinkle the code with std:: liberally if you want to be standards-compliant with c++29 or whatever you're targeting. For instance, I fixed json_writer.cpp in a different way by adding six std::

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your great modern compilers which support them without the std:: qualifier are leading you astray

Some older compilers have problems with std:: sometimes, and sscanf in particular can be available in weird ways. We'll be standards compliant in 2.0, but for now it's helpful to some users if we avoid being too strict.

I'll let you think on this a while before I do any reverting.

Don't revert. But can you wrap the new include lines in and ifdef for your compiler? IIRC, some modern compilers actually do not include the old headers, or consider them a compiler warning (which becomes an error with -Werror).

For instance, I fixed json_writer.cpp in a different way by adding six std::

Could you show us where? We can't add that on 0.y.z, but on master I think that would be fine.

@cdunn2001
Copy link
Contributor

Not sure about this anymore. Rebase and reopen if important.

@cdunn2001 cdunn2001 closed this Jun 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants