9 June 2008

VC++: stdio.h(358) : error C3163: '_vsnprintf': attributes inconsistent with previous declaration

Symptom:

When I tried to compile a project, which uses WinPcap library, on Visual C++ 2008 Express Edition, I got the following error message:

C:\DevTools\Microsoft Visual Studio 9.0\VC\include\stdio.h(358) : error C3163: '_vsnprintf': attributes inconsistent with previous declaration

Cause:

Microsoft decided to define vsnprintf in VS 2008 release. Many libraries, such as WinPcap, defined vsnprintf function by themselves because vsnprintf does not exist in previous versions of stdio.h.

Solution (WinPcap) 1:

Comment the following line in pcap-stdinc.h:

// #define vsnprintf _vsnprintf

Solution (WinPcap) 2:

If you still need to switch back and forth between VC2005 and VC2008, replace the following line in pcap-stdinc.h:

#define vsnprintf _vsnprintf

with

#if     _MSC_VER < 1500
#define vsnprintf _vsnprintf
#endif

1 comment:

0x00000000 said...

Thanks a lot. problem solved.