Wrong header guard

Minor issues with the Ogre API that can be trivial to fix
Post Reply
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Wrong header guard

Post by Klaim » Wed Aug 01, 2012 4:41 pm

I think it is not really a problem but it might mask problems:

https://bitbucket.org/sinbad/ogre/src/3 ... erSuffix.h

Code: Select all

#ifndef __OgreHeaderPrefix_H__
#define __OgreHeaderPrefix_H__
Problems:
1. this is OgreHeaderSuffix.h ...
2. OgreHeaderPrefix.h exists and have the same header guards.

In fact I was looking for which warnings are deactivated in Ogre. It looks like they are deactivated there but it's not included everywher (am I right?).
So here the pragma pop is never called, making the warning still be disabled after inclusion of, say , Singleton.h.
0 x

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
Contact:

Re: Wrong header guard

Post by masterfalcon » Wed Aug 01, 2012 4:49 pm

Good find. I'll commit it tonight.
0 x

User avatar
Antodologo
Halfling
Posts: 46
Joined: Tue Jul 13, 2010 4:05 pm
Contact:

Re: Wrong header guard

Post by Antodologo » Sun Sep 09, 2012 3:44 am

I would say you have forgotten

Code: Select all

#undef __OgreHeaderPrefix_H__
at the end of "OgreHeaderPrefix.h" to be able to call "push" and "pragma warning disable" several times in the same compilation


Currently, compiling Ogre 1.8.1 throws hundreds of Warnings (C4251, C4275 are way too common). Even with that #undef, most warnings are still there in our "Visual Studio 2008 Express" solution, because OgreHeaderPrefix/Suffix are included in just a few places.

Any smart way to ignore them all without deactivating warnings in the compiler? The annoying part is we get the warnings when compiling our own code using Ogre as a dynamic library.

Thanks
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: Wrong header guard

Post by Klaim » Sun Sep 09, 2012 9:49 am

Unfortunately the clean solution seems not easy to setup.
See this thread for more detail: http://www.ogre3d.org/forums/viewtopic.php?f=4&t=71345
0 x

User avatar
Antodologo
Halfling
Posts: 46
Joined: Tue Jul 13, 2010 4:05 pm
Contact:

Re: Wrong header guard

Post by Antodologo » Sun Sep 09, 2012 11:50 am

Thanks for the link! ;)

I think I can help there and you have discovered me the real problem. I knew the headers were fixed, but if that is the origin of the warning nightmare I will just break the headers in my code to avoid the warnings and that is all I need for now :P

Not so difficult to setup (but a dirty, dirty hack) :D
0 x

User avatar
nec
Gremlin
Posts: 175
Joined: Fri Sep 29, 2006 5:56 pm
Location: Rosny Sous Bois, France
Contact:

Re: Wrong header guard

Post by nec » Sun Mar 24, 2013 4:59 pm

I think this prefix/suffix pattern could probably be implemented like this as the include guards doesn't have very much meaning here.

OgreHeaderPrefix

Code: Select all


#ifdef __OgreHeaderPrefix_H__
#error at this point __OgreHeaderPrefix_H__ must not be defined
#endif

#define __OgreHeaderPrefix_H__

#include "OgrePrerequisites.h"

#if OGRE_COMPILER == OGRE_COMPILER_MSVC

// Save warnings state
#pragma warning (push)

#pragma warning (disable : 4786)
#pragma warning (disable : 4503)
#pragma warning (disable : 4251)
#pragma warning (disable : 4275)
#pragma warning( disable : 4290 )
#pragma warning( disable: 4661)
#pragma warning( disable: 4996)
#pragma warning (disable : 201)
#pragma warning (disable : 4100)

#endif

OgreHeaderSuffix

Code: Select all


#ifndef __OgreHeaderPrefix_H__
  #error at this point __OgreHeaderPrefix_H__ must be defined
#endif

#include "OgrePrerequisites.h"

#if OGRE_COMPILER == OGRE_COMPILER_MSVC

// restore previous warnings settings
#pragma warning (pop)

#endif

// allow inclusion of prefix again now (this is scoped)
#undef __OgreHeaderPrefix_H__

0 x

Post Reply