json: error C2039: '_snprintf': is not a member of 'std' - Windows

I used the latest release (single include file), compiled using VS2017 - Visual Studio 2017 Developer Command Prompt v15.9.1.

As a work around I removed std:: from all the snprintf calls.

I was building an addon for kodi: https://github.com/kodi-pvr/pvr.vuplus/pull/156

Full gist of build output: https://gist.github.com/phunkyfish/c8456619bd85c16b1f9243e83517ac46

Note that it builds for all other platforms without issue.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 28 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I experienced this issue with Visual Studio 2015. My application used Python as embedded scripting language, and pyerror.h redefines snprintf to _snprintf if configuration property HAVE_SNPRINTF is not defined. When I added HAVE_SNPRINTF definition to my project, json.hpp started to compile. So, it looks like Microsoft itself doesn’t redefine snprintf, however, software that supports compatibility with older Visual Studio versions may create such definition, especially if it is configured in incorrect way.

So, when you have such issue, first of all you have to review other open source dependencies that you have in your project.

No, it’s not the library‘s job to clean up such names.

std::snprintf is C++11 standards-compliant, and whoever has issues compiling that, should take care of fixing the issue.

Fair point. 😃

Are you sure this definition is from VC++ itself and not some other library that you’re including?

Sigh… Yet another instance where I need to “patch” C++11 code such that it can compile with the most recent Microsoft compiler…