JACoders / OpenJK

Community effort to maintain and improve Jedi Academy (SP & MP) + Jedi Outcast (SP only) released by Raven Software
GNU General Public License v2.0
2.01k stars 612 forks source link

Still having gcc warnings (now treated as errors) #300

Closed haoNoQ closed 10 years ago

haoNoQ commented 11 years ago

Having this sort of compile errors, for example:

Git revision is 035db67e076a173e3c0ce61760cc8a4d023d68b4
No build type selected, default to RELEASE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/noq/openjk/OpenJK/build
Scanning dependencies of target openjk_sp.i386
[  1%] Building CXX object code/CMakeFiles/openjk_sp.i386.dir/client/cl_cgame.cpp.o
/home/noq/openjk/OpenJK/code/client/cl_cgame.cpp: In function ‘void CL_InitCGame()’:
/home/noq/openjk/OpenJK/code/client/cl_cgame.cpp:1450:7: error: variable ‘t1’ set but not used [-Werror=unused-but-set-variable]
/home/noq/openjk/OpenJK/code/client/cl_cgame.cpp:1450:11: error: variable ‘t2’ set but not used [-Werror=unused-but-set-variable]
/home/noq/openjk/OpenJK/code/client/cl_cgame.cpp: In function ‘void CL_AdjustTimeDelta()’:
/home/noq/openjk/OpenJK/code/client/cl_cgame.cpp:1580:7: error: variable ‘resetTime’ set but not used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
make[2]: *** [code/CMakeFiles/openjk_sp.i386.dir/client/cl_cgame.cpp.o] Error 1
make[1]: *** [code/CMakeFiles/openjk_sp.i386.dir/all] Error 2
make: *** [all] Error 2

Will try to eliminate them myself. Using gcc 4.7.1 20120721 (linux x86)

haoNoQ commented 11 years ago

Some of the more interesting errors include:

[  0%] Building CXX object code/CMakeFiles/openjk_sp.i386.dir/client/cl_scrn.cpp.o
[  1%] Building CXX object code/CMakeFiles/openjk_sp.i386.dir/client/cl_ui.cpp.o                                       
/home/noq/openjk/OpenJK/code/client/cl_ui.cpp: In function ‘int FloatAsInt(float)’:
/home/noq/openjk/OpenJK/code/client/cl_ui.cpp:150:13: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
cc1plus: all warnings being treated as errors
make[2]: *** [code/CMakeFiles/openjk_sp.i386.dir/client/cl_ui.cpp.o] Error 1
make[1]: *** [code/CMakeFiles/openjk_sp.i386.dir/all] Error 2
make: *** [all] Error 2

and

Scanning dependencies of target openjk_sp.i386
[  0%] Building CXX object code/CMakeFiles/openjk_sp.i386.dir/client/snd_music.cpp.o
[  0%] Building CXX object code/CMakeFiles/openjk_sp.i386.dir/qcommon/cm_load.cpp.o
/home/noq/openjk/OpenJK/code/qcommon/cm_load.cpp:1313:12: error: multi-character character constant [-Werror=multichar]
/home/noq/openjk/OpenJK/code/qcommon/cm_load.cpp:1326:10: error: multi-character character constant [-Werror=multichar]
cc1plus: all warnings being treated as errors
make[2]: *** [code/CMakeFiles/openjk_sp.i386.dir/qcommon/cm_load.cpp.o] Error 1
make[1]: *** [code/CMakeFiles/openjk_sp.i386.dir/all] Error 2
make: *** [all] Error 2
haoNoQ commented 11 years ago

What i have so far: http://pastebin.com/JvnJ5HJx

haoNoQ commented 11 years ago

hmm ... or maybe the endianness is the other way round? ... i guess better not trust me on that.

eezstreet commented 11 years ago

Please try and avoid quadruple-posting like this, some of us don't appreciate the mass emails. Thanks. Anyway, don't treat the warnings as errors in the compiler, I don't think all warnings are necessarily able to be eliminated in all cases (see: MSVC warning 4996, which floods the compiler every time you DARE use strcmp/stricmp/strcpy/strncpy/strncat)

ensiform commented 11 years ago

I've dealt with most of the ones you've shown. Going to leave the multi-character as is for now and have @xycaleth deal with them. We don't want to change what gets written to the save files so we have to be extra careful size/type wise. And as im on msvc/windows I can't see these errors.

Yberion commented 11 years ago

Using this makefile : https://github.com/Yberion/OpenJK/blob/master/codemp/Makefile

I get these errors : http://pastebin.com/8GfPPivs

ensiform commented 11 years ago

That makefile isn't supported.

ensiform commented 11 years ago

Bump multi char constants: http://slexy.org/view/s20hf84fPd unsigned long's should probably get replaced to uint32_t with regards to chid stuff.

ensiform commented 11 years ago

I think these aren't errors anymore and most of the warnings are gone. @xycaleth / @haoNoQ close?

haoNoQ commented 11 years ago

Here's what i have:

cmake -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_C_FLAGS=-m32 -DCMAKE_SHARED_LINKER_FLAGS=-m32 -DCMAKE_SIZEOF_VOID_P=4 .. > cmake.haoNoQ.log 2>&1

http://pastebin.com/pRsLrTN5

make -j5 > make.haoNoQ.log 2>&1

http://pastebin.com/qG2sWdFz

That's a lot of warnings, but they're mostly simple.

ensiform commented 11 years ago

But the linux builders aren't producing nearly that many warnings.

xycaleth commented 11 years ago

Debian (used by the builder) uses an older version of GCC which may not be so strict in its default warning reporting.