Pages: [1]
|
 |
|
Author
|
Topic: Windows MSVC vsnprintf error when compiling (Read 6677 times)
|
Reath
Zebranky food

Offline
Posts: 2
|
I've searched on how to fix this and was able to fix most of the errors, but I still get 8 errors.
stdio.c C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(358) : error C3163: '_vsnprintf': attributes inconsistent with previous declaration C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(350) : see declaration of '_vsnprintf' uioutils.c C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(358) : error C3163: '_vsnprintf': attributes inconsistent with previous declaration C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(350) : see declaration of '_vsnprintf' uiostream.c C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(358) : error C3163: '_vsnprintf': attributes inconsistent with previous declaration C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(350) : see declaration of '_vsnprintf' paths.c C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(358) : error C3163: '_vsnprintf': attributes inconsistent with previous declaration C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(350) : see declaration of '_vsnprintf' mount.c C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(358) : error C3163: '_vsnprintf': attributes inconsistent with previous declaration C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(350) : see declaration of '_vsnprintf' ioaux.c C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(358) : error C3163: '_vsnprintf': attributes inconsistent with previous declaration C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(350) : see declaration of '_vsnprintf' fileblock.c C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(358) : error C3163: '_vsnprintf': attributes inconsistent with previous declaration C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(350) : see declaration of '_vsnprintf' defaultfs.c C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(358) : error C3163: '_vsnprintf': attributes inconsistent with previous declaration C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(350) : see declaration of '_vsnprintf'
|
|
|
Logged
|
|
|
|
Elestan
*Smell* controller
   
Offline
Posts: 431
|
This is happening because you're building in VC9, when the code is set up to build with VC6. VC6 did not have vsnprintf(), so UQM wrote its own. One of the later versions of VC added vsnprintf, but it doesn't work quite the way the C language standard says it should work. However it does create a name clash with the custom vsnprintf in UQM. The solution is to rename UQM's vsnprintf to something unique.
I have a patch that upgrades the current SVN tip to build in VC10; I've extracted the parts that deal with the vsnprintf problem. It may not apply cleanly to the 0.7.0 release code, but it should give you a starting point.
Good luck!
Index: sc2/src/uqm.c =================================================================== --- sc2/src/uqm.c (revision 3779) +++ sc2/src/uqm.c (working copy) @@ -508,7 +508,7 @@ ++len; --left; } - vsnprintf (errBuffer + len, left, fmt, list); + uqm_vsnprintf (errBuffer + len, left, fmt, list); errBuffer[sizeof (errBuffer) - 1] = '\0'; }
Index: sc2/src/libs/log/uqmlog.c =================================================================== --- sc2/src/libs/log/uqmlog.c (revision 3779) +++ sc2/src/libs/log/uqmlog.c (working copy) @@ -185,7 +185,7 @@ log_addV (log_Level level, const char *fmt, va_list list) { log_Entry full_msg; - vsnprintf (full_msg, sizeof (full_msg) - 1, fmt, list); + uqm_vsnprintf (full_msg, sizeof (full_msg) - 1, fmt, list); full_msg[sizeof (full_msg) - 1] = '\0';
if ((int)level <= maxStreamLevel) @@ -221,7 +221,7 @@ log_add_nothreadV (log_Level level, const char *fmt, va_list list) { log_Entry full_msg; - vsnprintf (full_msg, sizeof (full_msg) - 1, fmt, list); + uqm_vsnprintf (full_msg, sizeof (full_msg) - 1, fmt, list); full_msg[sizeof (full_msg) - 1] = '\0';
if ((int)level <= maxStreamLevel) Index: sc2/src/port.c =================================================================== --- sc2/src/port.c (revision 3779) +++ sc2/src/port.c (working copy) @@ -115,9 +115,9 @@ #endif
#ifdef _MSC_VER -// MSVC does not have snprintf() and vsnprintf(). It does have a _snprintf() -// and _vsnprintf(), but these do not terminate a truncated string as -// the C standard prescribes. +// MSVC's _snprintf() and vsnprintf() +// do not terminate a truncated string as the C standard +// prescribes. Create our own wrappers to do so. int snprintf(char *str, size_t size, const char *format, ...) { @@ -133,8 +133,9 @@ return result; }
+// This wrapper needs a custom name, because MSVC already has vsnprintf. int -vsnprintf(char *str, size_t size, const char *format, va_list args) +uqm_vsnprintf(char *str, size_t size, const char *format, va_list args) { int result = _vsnprintf (str, size, format, args); if (str != NULL && size != 0) Index: sc2/src/port.h =================================================================== --- sc2/src/port.h (revision 3779) +++ sc2/src/port.h (working copy) @@ -176,12 +176,15 @@ #if defined(__cplusplus) extern "C" { #endif +// Wrappers to get standard-compliant behavior on these functions. int snprintf(char *str, size_t size, const char *format, ...); -int vsnprintf(char *str, size_t size, const char *format, va_list args); +int uqm_vsnprintf(char *str, size_t size, const char *format, va_list args); #if defined(__cplusplus) } #endif - +#else /* !_MSC_VER */ +// No hack needed for non-MSVC; redef back to normal +#define uqm_vsnprintf vsnprintf #endif /* _MSC_VER */
#if defined(__cplusplus)
|
|
|
Logged
|
|
|
|
Gekko
*Many bubbles*
  
Offline
Gender: 
Posts: 199

Arena regular
|
If after Elestan's suggestion you still have problems, take a look at Oldlaptop's UQM Crossbuilder. It's a image that you can put on CD or boot in VirtualBox and compile UQM on Linux for WIndows. Details on usage.
|
|
|
Logged
|
|
|
|
Reath
Zebranky food

Offline
Posts: 2
|
Ok, thank you for the help! If I have anymore problems I'll let you know. Sorry for the late reply
|
|
|
Logged
|
|
|
|
Pages: [1]
|
|
|
|
|