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

Unable to compile on MSVC 2015 with SDL checking enabled: This function or variable may be unsafe. #149

Closed
dmartyn-0 opened this issue Nov 19, 2015 · 5 comments
Labels

Comments

@dmartyn-0
Copy link

When this library is compiled under MSVC 2015 with SDL checking on, compilation fails with this error:

C4996 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

The error occurs here at line 4694:
image

edit: This occurs with the latest release available from the releases list.

@whackashoe
Copy link
Contributor

snprintf could work. Otherwise, to disable you could do:


#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

@whackashoe
Copy link
Contributor

From a bit of reading looks like snprintf is a bit variable between os... might it be useful to just skip sprintf altogether and do it manually?

whackashoe added a commit to whackashoe/json that referenced this issue Nov 19, 2015
whackashoe added a commit to whackashoe/json that referenced this issue Nov 19, 2015
@whackashoe
Copy link
Contributor

heh - i messed up trying to rewrite a character ^^

@nlohmann can you take a look at this and if you're ok with it I can do a pull request, think its perhaps less shitty than alternatives. we can also probably take out include on cstdio but not positive on that.

@nlohmann nlohmann added the platform: visual studio related to MSVC label Dec 6, 2015
@nlohmann
Copy link
Owner

nlohmann commented Dec 6, 2015

Hi @whackashoe, thanks for looking into the issue. I would love to see a pull request with your replacement!

nlohmann added a commit that referenced this issue Dec 7, 2015
Replace sprintf with hex function, this fixes #149
@Stateford
Copy link

https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp#L7658

I'm running into this issue again. Looks like there's another call to snprintf here.

Looks like it was added 7.25.2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants