Jump to content

[9612] <varargs.h> causes gcc compile to fail


Recommended Posts

Posted

Latest commit causes gcc to fail:

In file included from ../../../src/game/Unit.cpp:53:
/usr/lib/gcc/i486-linux-gnu/4.4.1/include/varargs.h:4:2: error: #error "GCC no longer implements <varargs.h>."
/usr/lib/gcc/i486-linux-gnu/4.4.1/include/varargs.h:5:2: error: #error "Revise your code to use <stdarg.h>."
../../../src/game/Unit.cpp: In member function ‘void Unit::SendMonsterMove(float, float, float, SplineType, SplineFlags, uint32, Player*, ...)’:
../../../src/game/Unit.cpp:372: warning: ‘float’ is promoted to ‘double’ when passed through ‘...’
../../../src/game/Unit.cpp:372: note: (so you should pass ‘double’ not ‘float’ to ‘va_arg’)
../../../src/game/Unit.cpp:372: note: if this code is reached, the program will abort
../../../src/game/Unit.cpp:373: warning: ‘float’ is promoted to ‘double’ when passed through ‘...’
../../../src/game/Unit.cpp:373: note: if this code is reached, the program will abort
../../../src/game/Unit.cpp:374: warning: ‘float’ is promoted to ‘double’ when passed through ‘...’
../../../src/game/Unit.cpp:374: note: if this code is reached, the program will abort
../../../src/game/Unit.cpp:381: warning: ‘float’ is promoted to ‘double’ when passed through ‘...’
../../../src/game/Unit.cpp:381: note: if this code is reached, the program will abort

skinlayers

Posted

#include <varargs.h>

could be replaced by

#include <stdarg.h>

I think the new code added is at least problematic also.

If we use variable arguments (the ... at the end of the argument list), we should not use float

because the compiler convert any float to double when put it onto the stack.

So the va_arg() macro will skip 4 bytes instead of 8 bytes. This could be a problem.

Posted

Here is my proposed change:

diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 6d439f5..4b6c887 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -369,16 +369,16 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, SplineTy
            return;
        case SPLINETYPE_FACINGSPOT:                         // facing spot, not used currently
        {
-            data << float(va_arg(vargs,float));
-            data << float(va_arg(vargs,float));
-            data << float(va_arg(vargs,float));
+            data << float(va_arg(vargs,double));
+            data << float(va_arg(vargs,double));
+            data << float(va_arg(vargs,double));
            break;
        }
        case SPLINETYPE_FACINGTARGET:
            data << uint64(va_arg(vargs,uint64));
            break;
        case SPLINETYPE_FACINGANGLE:                        // not used currently
-            data << float(va_arg(vargs,float));             // facing angle
+            data << float(va_arg(vargs,double));             // facing angle
            break;
    }

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use