header guard and warning issues
-
- OGRE Retired Team Member
- Posts: 2903
- Joined: Thu Jan 18, 2007 2:48 pm
- x 58
Re: stable 1.8 branch not very stable!? [rev: 3717]
I already did that in the v1-8 branch for OgreMain. But plugins and components still generate a lot of warnings because most of the headers do not use the guards at all, so they need to be edited to include the guards.
-
- Kobold
- Posts: 39
- Joined: Fri Jun 06, 2008 1:59 pm
- Location: Germany
Re: stable 1.8 branch not very stable!? [rev: 3717]
I'm currently doing that for each Ogre header which I'm including (our own projects always build with /Wx [treat warnings as errors]) so every broken header is a big showstopper
The best solution so far with the current codebase state seems to be to add the prefix/suffix headers to Ogre.h and let them embrace all the other includes. Then put the Ogre.h in the precompiled header and it's pretty much done.
Also, I've taken a different approach now to manage multiple prefix/suffix header inclusions. I've build a fixed stack for inclusions which is incremented by the Prefix header and decremented by the Suffix header:
It's ugly and it allows only for a fixed count of nested inclusions but it works 

Also, I've taken a different approach now to manage multiple prefix/suffix header inclusions. I've build a fixed stack for inclusions which is incremented by the Prefix header and decremented by the Suffix header:
Code: Select all
#if defined(__OgreHeaderPrefix_H__0)
#define __OgreHeaderPrefix_H__1
#undef __OgreHeaderPrefix_H__0
#elif defined(__OgreHeaderPrefix_H__1)
#define __OgreHeaderPrefix_H__2
#undef __OgreHeaderPrefix_H__1
#elif defined(__OgreHeaderPrefix_H__2)
#define __OgreHeaderPrefix_H__3
#undef __OgreHeaderPrefix_H__2
#elif defined(__OgreHeaderPrefix_H__3)
#define __OgreHeaderPrefix_H__4
#undef __OgreHeaderPrefix_H__3
#elif defined(__OgreHeaderPrefix_H__4)
#define __OgreHeaderPrefix_H__5
#undef __OgreHeaderPrefix_H__4
#elif defined(__OgreHeaderPrefix_H__5)
#error("Add more stack levels to OgreHeaderPrefix.h")
#else
#define __OgreHeaderPrefix_H__0
// push warnings state and disable warnings here...
#include "OgrePrerequisites.h"
#endif
Code: Select all
#if defined(__OgreHeaderPrefix_H__5)
#define __OgreHeaderPrefix_H__4
#undef __OgreHeaderPrefix_H__5
#elif defined(__OgreHeaderPrefix_H__4)
#define __OgreHeaderPrefix_H__3
#undef __OgreHeaderPrefix_H__4
#elif defined(__OgreHeaderPrefix_H__3)
#define __OgreHeaderPrefix_H__2
#undef __OgreHeaderPrefix_H__3
#elif defined(__OgreHeaderPrefix_H__2)
#define __OgreHeaderPrefix_H__1
#undef __OgreHeaderPrefix_H__2
#elif defined(__OgreHeaderPrefix_H__1)
#define __OgreHeaderPrefix_H__0
#undef __OgreHeaderPrefix_H__1
#elif defined(__OgreHeaderPrefix_H__0)
#undef __OgreHeaderPrefix_H__0
#if OGRE_COMPILER == OGRE_COMPILER_MSVC
// restore previous warnings settings
# pragma warning (pop)
#endif
#else
#error("Add more stack levels to OgreHeaderPrefix.h!")
#endif

Working at Z-Software
-
- OGRE Team Member
- Posts: 1525
- Joined: Fri Feb 03, 2006 10:37 pm
- Location: Austria - Leoben
- x 100
Re: stable 1.8 branch not very stable!? [rev: 3717]
In 1.9 i guarded much more but iam still not done - but for 1.9 i can also guard components.
-
- OGRE Expert User
- Posts: 1227
- Joined: Thu Dec 11, 2008 7:56 pm
- Location: Bristol, UK
- x 157
Re: header guard and warning issues
NB. Changed the topic of top post so its more relevant to this forum
-
- Kobold
- Posts: 39
- Joined: Tue Dec 23, 2008 9:55 pm
- x 5
Re: header guard and warning issues
Folks,
does this got fixed? I am migrating to VS2012 and getting a lot of those warnings about pragma pop, even using the code from mercurial.
The tons of warnings from compiling ogre code does not bother me, but when I compile my code, I got those warnings as well.
Thank you
does this got fixed? I am migrating to VS2012 and getting a lot of those warnings about pragma pop, even using the code from mercurial.
The tons of warnings from compiling ogre code does not bother me, but when I compile my code, I got those warnings as well.
Thank you
-
- Old One
- Posts: 2565
- Joined: Sun Sep 11, 2005 1:04 am
- Location: Paris, France
- x 56
Re: header guard and warning issues
It's supposed to be fixed in 1.9 at least but I've seen a recent bug about missing files in one configuration. Check https://ogre3d.atlassian.net/browse/OGRE-95 there seem to be a patch.
-
- Kobold
- Posts: 39
- Joined: Tue Dec 23, 2008 9:55 pm
- x 5
Re: header guard and warning issues
Thanks! I am seeing the fix in 1.9, I will try that.
Cheers
Cheers
-
- Goblin
- Posts: 257
- Joined: Tue Sep 02, 2008 9:41 pm
- x 1
Re: stable 1.8 branch not very stable!? [rev: 3717]
I found this thread from http://www.ogre3d.org/forums/viewtopic.php?f=1&t=76751 after having the same problem. But I don't think I agree with this:
We already have files which are only included on specific platforms, and aren't even part of the project on others. Isn't it possible that when configuring CMake and you tell it the compiler to use, MSVC builds could include the prefix header and for everything else it gets left out entirely?Wolfmanfx wrote:Yes i disabled the same warnings than before.
Yeah i applied it just for OGRE projects.
I thought about and maybe i just think the wrong way but i do not see any benefits to clutter the whole ogre codebase with the prefix/suffix header to disable MSVC specific warnings (we have also clang, gcc).