VS2017 #error: : Macro definition of snprintf conflicts with Standard Library function declaration
As the error in your question shows, you have a macro definition for snprintf
that is no longer compatible with your current version.
So you need to look for the following:
#define snprintf _snprintf
You can either remove it or if you need to also compile your code with Visual Studio 2010 you can add the following condition:
#if _MSC_VER < 1700
#define snprintf _snprintf
#endif
VS 2015 compiling cocos2d-x 3.6 error Macro definition of snprintf conflicts with Standard Library function declaration
I am getting the same error trying to build libsndfile-1. I solved it by building using VS2013 instead of VS2015. (I think it should be possible to simply install VS2013 Build Tools and build from VS2015).
edit: to install the VS2013 build toolset, run the VS2015 installer and select 'Windows 8.1 and Windows Phone 8.0/8.1 Tools'
The error notes that Macro definition of snprintf conflicts with Standard Library function declaration when debug the LZO
I used
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
Still learning c++, started a few weeks ago, so I don't know EXACTLY how this fixes it, other then only having to define it on VS versions below 2015. Here's where I found the answer
https://forum.juce.com/t/solved-error-with-vs2015-regarding-snprintf/14831/3
Visual Studio: Macro definition of snprintf conflict
Visual Studio 14+ defines snprintf
to _snprintf
in stdio.h
.
Your code (or 3rd-party code you include) probably also defines it in the same way, hence it doesn't work.
Search for a line like this:
#define snprintf _snprintf
And change it to:
#if _MSC_VER < 1900
# define snprintf _snprintf
#endif
How to search in Visual Studio:
- Edit -> Find and replace -> Search in Files... (Ctrl+Shift+F)
- Find what:
#\s*define\s+snprintf
- Look in:
Entire Solution ( Including External Items ) - Match case
- Use Regular Expressions
- Find All...
Related Topics
Using Shared_Ptr in Dll-Interfaces
Debug and Release Library Linking with Cmake (Visual Studio)
When Pass-By-Pointer Is Preferred to Pass-By-Reference in C++
How to Disable Warnings for Particular Include Files
Mechanism of Vptr and Vtable in C++
C++ Linker Error with Class Static Constexpr
Inspecting Stl Containers in Visual Studio Debugging
C++ Cout and Cin Buffers, and Buffers in General
Forward Declaration VS Include
Compile-Time Map and Inverse Map Values
When to Use Extern "C" in Simple Words
How to Enable /Std:C++17 in VS2017 with Cmake
How to Get Cmake to Recognize Pthread on Ubuntu
Std::This_Thread::Sleep_For() and Gcc