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)
|