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

coder 1 Reputation point
2022-08-19T15:01:46.82+00:00

iam trying to build a solution getting below error .Can anyone help me to solve issue.

Severity Code Description Project File Line Suppression State
Error C1189 #error: Macro definition of snprintf conflicts with Standard Library function declaration f c:\program files (x86)\windows kits\10\include\10.0.17763.0\ucrt\stdio.h 1935
getting error in below lines

#if defined snprintf
// This definition of snprintf will generate "warning C4005: 'snprintf': macro
// redefinition" with a subsequent line indicating where the previous definition
// of snprintf was. This makes it easier to find where snprintf was defined.
#pragma warning(push, 1)
#pragma warning(1: 4005)
#define snprintf Do not define snprintf as a macro
#pragma warning(pop)
#error Macro definition of snprintf conflicts with Standard Library function declaration

#endif

_Success_(return >= 0)  
_Check_return_opt_  
_CRT_STDIO_INLINE int __CRTDECL snprintf(  
    _Out_writes_opt_(_BufferCount) _Always_(_Post_z_) char*       const _Buffer,  
    _In_                                              size_t      const _BufferCount,  
    _In_z_ _Printf_format_string_                     char const* const _Format,  
    ...)  
#if defined _NO_CRT_STDIO_INLINE  
;  
#else  
{  
    int _Result;  
    va_list _ArgList;  
    __crt_va_start(_ArgList, _Format);  
#pragma warning(suppress:28719)    // 28719  
    _Result = vsnprintf(_Buffer, _BufferCount, _Format, _ArgList);  
    __crt_va_end(_ArgList);  
    return _Result;  
}  
#endif  

_Success_(return >= 0)  
_Check_return_opt_  
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,527 questions
{count} votes

1 answer

Sort by: Most helpful
  1. WayneAKing 4,921 Reputation points
    2022-08-19T19:47:12.497+00:00

    I don't see where you have stated which version of VS you are using.

    Have you read these threads?

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

    https://stackoverflow.com/questions/52179282/vs2017-error-macro-definition-of-snprintf-conflicts-with-standard-library-fu

    VS 2015 compiling cocos2d-x 3.3 error "fatal error C1189: #
    error: Macro definition of snprintf conflicts with Standard
    Library function declaration"

    https://stackoverflow.com/questions/27754492/vs-2015-compiling-cocos2d-x-3-3-error-fatal-error-c1189-error-macro-definiti

    • Wayne
    0 comments No comments