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
x 56
Contact:

Wrong header guard

Post by Klaim »

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.
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: Wrong header guard

Post by masterfalcon »

Good find. I'll commit it tonight.
User avatar
Antodologo
Halfling
Posts: 46
Joined: Tue Jul 13, 2010 4:05 pm
x 5
Contact:

Re: Wrong header guard

Post by Antodologo »

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
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: Wrong header guard

Post by Klaim »

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
User avatar
Antodologo
Halfling
Posts: 46
Joined: Tue Jul 13, 2010 4:05 pm
x 5
Contact:

Re: Wrong header guard

Post by Antodologo »

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
User avatar
nec
Gremlin
Posts: 175
Joined: Fri Sep 29, 2006 5:56 pm
Location: Rosny Sous Bois, France
x 11
Contact:

Re: Wrong header guard

Post by nec »

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__

Post Reply