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
- Fix snprintf not working correctly This seems to be an issue with Microsoft declaring a snprintf macro which causes issues. Related issues: - https://github.com/nlohmann/json/issues/1408 - https://git... — committed to jgoyvaerts/xenia by jgoyvaerts 5 years ago
- Fix snprintf not working correctly This seems to be an issue with Microsoft declaring a snprintf macro which causes issues. Related issues: - https://github.com/nlohmann/json/issues/1408 - https://git... — committed to jgoyvaerts/xenia by jgoyvaerts 5 years ago
- Fix snprintf not working correctly This seems to be an issue with Microsoft declaring a snprintf macro which causes issues. Related issues: - https://github.com/nlohmann/json/issues/1408 - https://git... — committed to Razzile/xenia by jgoyvaerts 5 years ago
- Fix snprintf not working correctly This seems to be an issue with Microsoft declaring a snprintf macro which causes issues. Related issues: - https://github.com/nlohmann/json/issues/1408 - https://git... — committed to jgoyvaerts/xenia by jgoyvaerts 5 years ago
- [Base] Fix snprintf not working correctly This seems to be an issue with Microsoft declaring a snprintf macro which causes issues. Related issues: - https://github.com/nlohmann/json/issues/1408 - http... — committed to jgoyvaerts/xenia by jgoyvaerts 5 years ago
- add a link to https://github.com/nlohmann/json/issues/1408 to clarify that the HAVE_SNPRINTF fix is json-related — committed to slayoo/PyPartMC by slayoo a year ago
I experienced this issue with Visual Studio 2015. My application used Python as embedded scripting language, and
pyerror.h
redefinessnprintf
to_snprintf
if configuration propertyHAVE_SNPRINTF
is not defined. When I addedHAVE_SNPRINTF
definition to my project,json.hpp
started to compile. So, it looks like Microsoft itself doesn’t redefinesnprintf
, 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.
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…