Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: Fixing warnings from -Wall  (Read 1954 times)

Olex

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 7
    • View Profile
    • http://ox.slug.louisville.edu/~o0lozi01/wiki
Fixing warnings from -Wall
« on: May 02, 2006, 08:20:29 PM »

I use -Wall during day-to-day coding.

So, I would like to submit warning fixes for OIS.

The warnings that I get under Linux GCC are of this type:
Code: [Select]
/usr/local/include/OIS/OISMouse.h:57: warning: ignoring #pragma warning
 /usr/local/include/OIS/OISMouse.h:58: warning: ignoring #pragma warning
 /usr/local/include/OIS/OISMouse.h:60: warning: ignoring #pragma warning
 /usr/local/include/OIS/OISEffect.h:174: warning: ignoring #pragma warning
 .h:175: warning: ignoring #pragma warning
 /usr/local/include/OIS/OISEffect.h:177: warning: ignoring #pragma warning
 /usr/local/include/OIS/OISEffect.h:221: warning: `OIS::PeriodicEffect::period' will be initialized after
 /usr/local/include/OIS/OISEffect.h:218: warning: `short unsigned int OIS::PeriodicEffect::magnitude'
 /usr/local/include/OIS/OISEffect.h:216: warning: when initialized here
 /usr/local/include/OIS/OISEffect.h:239: warning: `OIS::ConditionalEffect::leftSaturation' will be initialized after
 /usr/local/include/OIS/OISEffect.h:235: warning: `short int OIS::ConditionalEffect::rightCoeff'
 /usr/local/include/OIS/OISEffect.h:233: warning: when initialized here
 /usr/local/include/OIS/OISException.h:63: warning: `OIS::Exception::eText' will be initialized after
 /usr/local/include/OIS/OISException.h:59: warning: `const int OIS::Exception::eLine'
 /usr/local/include/OIS/OISException.h:54: warning: when initialized here


They come from this code:
Code: [Select]
       struct _OISExport PeriodicEffect : public ForceEffect
        {
                //problem line//PeriodicEffect() : period(0), magnitude(0), offset(0), phase(0) {}

                // now my fix
                PeriodicEffect() : magnitude(0), offset(0), phase(0), period(0) {}

                unsigned short magnitude;  //0 to 10,0000
                signed short   offset;
                unsigned short phase;      //Position at which playback begins 0 to 35,999
                unsigned int   period;     //Period of effect (microseconds)

                struct Envelope envelope;  //Optional Envelope
        };
Commented out constructor is the original line, the next one is mine to resolve those warning.

Warnings are clearly not critical in any way that I know of, but this makes by programming days easier, and it is almost nothing to fix this.

Here are other parts:
Code: [Select]
       struct _OISExport ConditionalEffect : public ForceEffect
        {
                //ConditionalEffect() : rightSaturation(0), leftSaturation(0),
                //      rightCoeff(0), leftCoeff(0), deadband(0), center(0) {}

                ConditionalEffect() : rightCoeff(0),leftCoeff(0),rightSaturation(0),
                                      leftSaturation(0), deadband(0), center(0) {}

                signed short   rightCoeff;      //-10k to +10k (Positive Coeff)
                signed short   leftCoeff;       //-10k to +10k (Negative Coeff)
           
and
Code: [Select]
       class _OISExport Exception
        {
                //! Hidden default
                Exception() : eType(E_General), eLine(0), eFile(0) {}
        public:
                //! Creates exception object
                Exception( OIS_ERROR err, const char* str, int line, const char *file )

// and now the following is fixed off warnings
                        : eType(err), eLine(line), eFile(file), eText(str) {}



The only other thing is left are
Code: [Select]
#pragma warning which gcc does not like. It states during compilations that those lines are ignored. For my Linux deps i simply commented those lines out, but a better solution would be to check if it's Linux or Windows platform and turn those lines off with a define check.
Logged
roject: URumble 2 using OPAL physics engine
Rumble Framework

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2653
    • View Profile
    • http://www.wreckedgames.com
Fixing warnings from -Wall
« Reply #1 on: May 02, 2006, 08:26:33 PM »

Perhaps this can be added to OIS for the next release, and since there are but a few #pragma's for wanrings (which, gcc should not even print out an message, god, wall is extremely anal).. I suppose they can be wrapped with some preprocessor stuff. I suggest you put a request on the feature tracker (on sf.net site) or supply a patch and post it on the patch tracker.. Though, seeing how anonymous cvs is fubar right now.. I suppose a patch would be off some really old code.. Or, would be very wierd anyway.

So, best to be a feature request.
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Fixing warnings from -Wall
« Reply #2 on: May 03, 2006, 12:05:31 AM »

VC++ has a -Wall as well and generally use it for my projects (freakin heck Ogre has a lot of warnings pop up then...).  Still good practice to not have warnings at all, I treat warnings as errors for my code to make sure it is as clean as possible.
Logged

Olex

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 7
    • View Profile
    • http://ox.slug.louisville.edu/~o0lozi01/wiki
Fixing warnings from -Wall
« Reply #3 on: May 03, 2006, 05:19:09 PM »

@pjcast: I have submitted a feature request for this.
Logged
roject: URumble 2 using OPAL physics engine
Rumble Framework

Olex

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 7
    • View Profile
    • http://ox.slug.louisville.edu/~o0lozi01/wiki
Fixing warnings from -Wall
« Reply #4 on: May 05, 2006, 06:16:32 AM »

I just got an email with update on this from SF. Thanks for the fix, pjcast.
Logged
roject: URumble 2 using OPAL physics engine
Rumble Framework

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2653
    • View Profile
    • http://www.wreckedgames.com
Fixing warnings from -Wall
« Reply #5 on: May 05, 2006, 08:25:00 AM »

No problem :)

After I get the Windows CodeBlock project files sorted out, I will start preparing to release 0.7 which will contain all the little bug fixes/enhancements of the last month.. Especially since sourceforge.net is having major CVS anonymous issues, better to release quickly so that people can use the new changes.
Logged