#101 Warnings when building on OpenSolaris

open-fixed
nobody
nuisance (37)
5
2009-02-03
2007-09-29
Moinak Ghosh
No

Building with gcc on OpenSolaris gives a couple of warnings and the build fails due to -Werror. The suggested fix tells all:

--- src/freeglut_joystick.c.orig Sat Sep 29 05:30:51 2007
+++ src/freeglut_joystick.c Sat Sep 29 05:35:12 2007
@@ -1065,6 +1065,12 @@
#endif

/*
+ * Suppress compiler warnings
+ */
+ i = 0;
+ counter = 0;
+
+ /*
* Default values (for no joystick -- each conditional will reset the
* error flag)
*/

Discussion

  • John F. Fay
    John F. Fay
    2007-09-29

    Logged In: YES
    user_id=70811
    Originator: NO

    Part of this seems to be overcome by events. The current SVN head has a statement there "(void)i;" with a comment "Silence gcc, the correct #ifdefs would be too fragile...". I do not want to put the same thing in for "counter" because it is only defined part of the time. Perhaps we should put a "(void)counter;" statement immediately after the variable definition on line 1064. Please try that and tell me what happens.

     
  • Nigel Stewart
    Nigel Stewart
    2009-02-02

    The following patch resolves the build failure by detecting Solaris and
    using the same codepath as linux. This should have no side-effects for
    other platforms. Tested on OpenSolaris 2008.11 with the gcc toolchain.

    *** freeglut-2.4.0/src/freeglut_internal.h 2005-06-02 17:39:32.000000000 -0500
    --- freeglut-2.4.0.fixed/src/freeglut_internal.h 2009-02-02 15:44:19.944875368 -0600
    ***************
    *** 52,57 ****
    --- 52,62 ----
    # define TARGET_HOST_WINCE 0
    #endif

    + /* Detect both SunPro and gcc compilers on Sun Solaris */
    + #if defined (__SVR4) && defined (__sun)
    + # define TARGET_HOST_SOLARIS 1
    + #endif
    +
    #define FREEGLUT_MAX_MENUS 3

    /* Somehow all Win32 include headers depend on this one: */
    diff -c -r freeglut-2.4.0/src/freeglut_joystick.c freeglut-2.4.0.fixed/src/freeglut_joystick.c
    *** freeglut-2.4.0/src/freeglut_joystick.c 2005-05-04 07:53:48.000000000 -0500
    --- freeglut-2.4.0.fixed/src/freeglut_joystick.c 2009-02-02 15:40:33.879045835 -0600
    ***************
    *** 1389,1395 ****
    # endif
    #endif

    ! #if defined( __linux__ )
    /* Default for older Linux systems. */
    joy->num_axes = 2;
    joy->num_buttons = 32;
    --- 1389,1395 ----
    # endif
    #endif

    ! #if defined( __linux__ ) || defined( TARGET_HOST_SOLARIS )
    /* Default for older Linux systems. */
    joy->num_axes = 2;
    joy->num_buttons = 32;

     
  • Nigel Stewart
    Nigel Stewart
    2009-02-02

    I would suggest upgrading the category of this from "nuisance" to "fatal with known workaround".

     
  • John F. Fay
    John F. Fay
    2009-02-02

    I have tried to match Nigel's suggested changes to the current SVN version and, I think, have succeeded. What I do not see is now they address the original problem about uninitialized "i" and "counter" variables. Both are initialized in the current SVN version, though, and so the original problem may have gone away.

    I have uploaded the changes to SVN where they form revision [762]. In keeping with the other "TARGET_HOST" macros I defined this one to be one for Solaris and 0 otherwise. Then I tested not for definition but for a nonzero (true) value.

    Please download the changed SVN version and, if it builds without warnings on Solaris, retire this ticket.

     
  • Nigel Stewart
    Nigel Stewart
    2009-02-03

    The problem was not uninitialized i and counter, it was that neither variable was used. The intent of my patch was to treat solaris the same as Linux, which at least results in a successful build. Couldn't say if joysticks actually work on solaris...

    I'll svn head on Solaris, and confirm here.

    Thanks John!

     
  • Nigel Stewart
    Nigel Stewart
    2009-02-03

    I needed to make two more changes to get a solaris gcc build:

    freeglut_main.c:311 #if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY
    freeglut_joystick.c:1063 # if defined( __linux__ ) || TARGET_HOST_SOLARIS

    Apart from these, looks good.

     
  • John F. Fay
    John F. Fay
    2009-02-03

    OK, I've put in the fixes. Again, try building with them and if they work, let's close this bug report.

     
  • Nigel Stewart
    Nigel Stewart
    2009-02-03

    Confirmed.
    Solaris gcc is now building svn revision 763, without issue.
    This bug can be closed, in my opinion.

     
  • John F. Fay
    John F. Fay
    2009-02-03

    • status: open --> open-fixed
     
  • Nigel Stewart
    Nigel Stewart
    2009-03-06

    John,

    Time for a new release. :-)

    - Nigel