#158 A couple of compiler warnings

open
nobody
nuisance (37)
5
2011-10-05
2011-10-05
paletta
No

Compiling r942 on Ubuntu 10.10 I get the following two compile warnings:
freeglut_gamemode.c:44:12: warning: 'xrandr_resize' defined but not used
CallbackMaker.c:529:9: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result

Full build log available here: https://launchpadlibrarian.net/81587043/buildlog_ubuntu-natty-i386.freeglut_2.6.0-1ubuntu2%2Bgd%7En%2B7_BUILDING.txt.gz

Discussion

  • Nigel Stewart
    Nigel Stewart
    2011-12-09

    I see something similar for reeglut_gamemode.c

    gcc4 -fPIC -Wall -Wno-switch -Wno-missing-braces -fvisibility=hidden -nostdinc ... -m32 -I. -Iinclude -g -DDEBUG -D_DEBUG -fno-exceptions -DHAVE_CONFIG_H=1 -o../../../../tools/cg/Common/freeglut-2.6.0/built/freeglutlib_Linux_gcc4_debug/freeglut_gamemode.o -c src/freeglut_gamemode.c
    src/freeglut_gamemode.c: In function ‘fghRememberState’:
    src/freeglut_gamemode.c:168: warning: unused variable ‘error_base’
    src/freeglut_gamemode.c:168: warning: unused variable ‘event_base’
    src/freeglut_gamemode.c: At top level:
    src/freeglut_gamemode.c:45: warning: ‘xrandr_resize’ defined but not used
    src/freeglut_geometry.c

    Note that this build has HAVE_X11_EXTENSIONS_XF86VMODE_H undefined.

     
  • Sorry I still can't reproduce it.
    I disabled XF86VidMode by changing the define lines in config.h to:
    #undef HAVE_LIBXXF86VM
    #undef HAVE_X11_EXTENSIONS_XF86VMODE_H
    and recompiled. The Xrandr code gets compiled as should be and gamemode works.

     
  • Hi Paletta,

    Do you still observe this issue in current trunk?

     
  • paletta
    paletta
    2012-12-08

    On 2.8.0 I still get these warnings:

    freeglut_gamemode.c:44:12: warning: 'xrandr_resize' defined but not used [-Wunused-function]
    freeglut_input_devices.c:204:16: warning: variable 'dials' set but not used [-Wunused-but-set-variable]
    freeglut_state.c:55:7: warning: variable 'result' set but not used [-Wunused-but-set-variable]
    freeglut_state.c:844:15: warning: variable 'result' set but not used [-Wunused-but-set-variable]
    freeglut_window.c:306:17: warning: variable 'result' set but not used [-Wunused-but-set-variable]
    CallbackMaker.c:435:7: warning: variable 'menuID' set but not used [-Wunused-but-set-variable]
    CallbackMaker.c:529:9: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result [-Wunused-result]
    fractals.c:306:7: warning: variable 'fractal_window' set but not used [-Wunused-but-set-variable]
    fractals_random.c:350:7: warning: variable 'fractal_window' set but not used [-Wunused-but-set-variable]
    lorenz.c:223:12: warning: variable 'dist' set but not used [-Wunused-but-set-variable]
    one.c:253:9: warning: variable 'menuID' set but not used [-Wunused-but-set-variable]

    Then it fails to build with:
    In file included from /usr/include/GL/gl.h:2085:0,
    from ../../../include/GL/freeglut_std.h:122,
    from ../../../include/GL/freeglut.h:17,
    from smooth_opengl3.c:45:
    /usr/include/GL/glext.h:6699:25: note: previous declaration of 'PFNGLSHADERSOURCEPROC' was here

    Full log here:
    https://launchpadlibrarian.net/123516257/buildlog_ubuntu-quantal-amd64.freeglut_2.8.0-1%7Eexp1%7Equantal1%7Egd_FAILEDTOBUILD.txt.gz

    I also tried on r1488 but I don't know how to build, there is no Makefile/autogen.sh/configure.

     
  • Hi Paletta,

    Thanks for trying things out! We have moved on quite a bit since 2.8.0. In fact, 2.8.1 is around the corner, grab a copy from:
    svn co https://freeglut.svn.sourceforge.net/svnroot/freeglut/tags/FG_2_8_1_RC1/freeglut
    This should build using a similar route as 2.8.0.

    For current trunk, we have switched to CMake as a buildsystem, hence the missing Makefile/autogen.sh/configure.

    Best,
    Dee

     
  • paletta
    paletta
    2012-12-18

    OK, I tried the 2.8.1 branch. There are still these warnings:
    freeglut_gamemode.c:44:12: warning: 'xrandr_resize' defined but not used [-Wunused-function]
    freeglut_input_devices.c:204:16: warning: variable 'dials' set but not used [-Wunused-but-set-variable]
    freeglut_state.c:55:7: warning: variable 'result' set but not used [-Wunused-but-set-variable]
    freeglut_state.c:881:15: warning: variable 'result' set but not used [-Wunused-but-set-variable]
    freeglut_window.c:299:17: warning: variable 'result' set but not used [-Wunused-but-set-variable]
    freeglut_xinput.c:172:4: warning: implicit declaration of function 'fgPlatformGetModifiers' [-Wimplicit-function-declaration]
    CallbackMaker.c: In function 'Warning':
    CallbackMaker.c:139:5: warning: format '%d' expects a matching 'int' argument [-Wformat]
    CallbackMaker.c: In function 'Error':
    CallbackMaker.c:149:5: warning: format '%d' expects a matching 'int' argument [-Wformat]
    CallbackMaker.c: In function 'main':
    CallbackMaker.c:467:7: warning: variable 'menuID' set but not used [-Wunused-but-set-variable]
    CallbackMaker.c:566:9: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result [-Wunused-result]
    CallbackMaker.c: In function 'Error':
    CallbackMaker.c:156:11: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result [-Wunused-result]

    Then it still fails to build with:
    /bin/bash ../../../libtool --tag=CC --mode=link i686-linux-gnu-gcc -I../../../include -g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -pedantic -export-dynamic -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -o CallbackMaker CallbackMaker-CallbackMaker.o ../../../src/libglut.la -lGL -lXext -lX11 -lXi -lXxf86vm
    libtool: link: i686-linux-gnu-gcc -I../../../include -g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -pedantic -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z -Wl,relro -Wl,-z -Wl,now -o .libs/CallbackMaker CallbackMaker-CallbackMaker.o -Wl,--export-dynamic ../../../src/.libs/libglut.so -lGL -lXext -lX11 -lXi -lXxf86vm
    ../../../src/.libs/libglut.so: undefined reference to `fgPlatformGetModifiers'
    collect2: error: ld returned 1 exit status
    make[5]: *** [CallbackMaker] Error 1

    Full build log here:
    https://launchpadlibrarian.net/126091350/buildlog_ubuntu-quantal-i386.freeglut_2.8.0-1~exp1%2Bsvn2_FAILEDTOBUILD.txt.gz