VS 2015 Compiling Cocos2D-X 3.3 Error "Fatal Error C1189: #Error: MACro Definition of Snprintf Conflicts with Standard Library Function Declaration"

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



Leave a reply



Submit