Skip to content

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

Closed

Description

@dmartyn-0

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.

Activity

  1. whackashoe commented on Nov 19, 2015

    @whackashoe
    Contributor

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

    
    #ifdef _MSC_VER
    #define _CRT_SECURE_NO_WARNINGS
    #endif
    
    
  2. whackashoe commented on Nov 19, 2015

    @whackashoe
    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?

  3. added 3 commits that reference this issue on Nov 19, 2015
    21e4083
    770ef80
    14d8a91
  4. whackashoe commented on Nov 19, 2015

    @whackashoe
    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.

  5. nlohmann commented on Dec 6, 2015

    @nlohmann
    Owner

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

  6. added a commit that references this issue on Dec 7, 2015
    f36f316
  7. Stateford commented on Mar 4, 2021

    @Stateford

    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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions