visual-studio-2015lzo

The error notes that Macro definition of snprintf conflicts with Standard Library function declaration when debug the LZO


I have compiled the original codes of lzo by cmake and I tried to debug the VS project lzo.sin,but the hint of VS noted that

#error:  Macro definition of snprintf conflicts with Standard Library function declaration,

enter image description here

Then I find someone said it was because of the VS2015 had defined snprintf,the codes in the project also defined it,hence came the errors.I replaced the codes #define snprintf _snprintf in the lzo_supp.h file with

#  ifndef
#    define snprintf _snprintf
#  endif

but the errors still remained.I don't know how to fix that.


Solution

  • 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