The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
December 05, 2024, 02:29:43 am
Home Help Search Login Register
News: Celebrating 30 years of Star Control 2 - The Ur-Quan Masters

+  The Ur-Quan Masters Discussion Forum
|-+  The Ur-Quan Masters Re-Release
| |-+  Technical Issues (Moderator: Death 999)
| | |-+  Windows MSVC vsnprintf error when compiling
« previous next »
Pages: [1] Print
Author Topic: Windows MSVC vsnprintf error when compiling  (Read 6084 times)
Reath
Zebranky food
*
Offline Offline

Posts: 2



View Profile
Windows MSVC vsnprintf error when compiling
« on: August 12, 2013, 03:39:23 am »

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 Offline

Posts: 431



View Profile
Re: Windows MSVC vsnprintf error when compiling
« Reply #1 on: August 25, 2013, 05:48:42 pm »

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!

Code:
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 Offline

Gender: Male
Posts: 199


Arena regular


View Profile
Re: Windows MSVC vsnprintf error when compiling
« Reply #2 on: August 25, 2013, 06:03:36 pm »

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

Visit #uqm-arena and play a game of Net Melee!
Try the Net Melee Improvement mod
Reath
Zebranky food
*
Offline Offline

Posts: 2



View Profile
Re: Windows MSVC vsnprintf error when compiling
« Reply #3 on: December 08, 2013, 08:03:39 pm »

Ok, thank you for the help! If I have anymore problems I'll let you know. Sorry for the late reply
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!