[SOLVED]Begginer Issue: Errors compiling with CEGUI headers
Moderators: CEGUI MVP, CEGUI Team
[SOLVED]Begginer Issue: Errors compiling with CEGUI headers
I'm getting piles of compiler errors in my app when I include the following files:
CEGUI/CEGUI.h
CEGUI/GUIContext.h
The first errors for each are "/usr/include/cegui-0/CEGUI/PropertyHelper.h|432|error: expected unqualified-id before numeric constant" and "/usr/include/cegui-0/CEGUI/SystemKeys.h|39|error: expected identifier before numeric constant" respectively.
I'm running Gentoo Linux, CEGUI 0.8.4, gcc-4.7.3, Code::Blocks 13.12, in case any of that is relevent.
I'm still trying to get a simple window to display on the screen, and I'm getting stumped. It's going to be something simple I'm getting wrong, but I can't see what it is.
CEGUI/CEGUI.h
CEGUI/GUIContext.h
The first errors for each are "/usr/include/cegui-0/CEGUI/PropertyHelper.h|432|error: expected unqualified-id before numeric constant" and "/usr/include/cegui-0/CEGUI/SystemKeys.h|39|error: expected identifier before numeric constant" respectively.
I'm running Gentoo Linux, CEGUI 0.8.4, gcc-4.7.3, Code::Blocks 13.12, in case any of that is relevent.
I'm still trying to get a simple window to display on the screen, and I'm getting stumped. It's going to be something simple I'm getting wrong, but I can't see what it is.
Last edited by Illiander on Wed Feb 25, 2015 09:51, edited 3 times in total.
Re: Begginer Issue: Errors compiling with CEGUI headers
Please post the specific line of code (in code tags) where the error occurs. This might help identify the issue.
Unfortunately I dont use the same OS or tools to reproduce this. Also I have never encountered such an error. Strange.
Unfortunately I dont use the same OS or tools to reproduce this. Also I have never encountered such an error. Strange.
CrazyEddie: "I don't like GUIs"
Re: Begginer Issue: Errors compiling with CEGUI headers
Illiander wrote:I'm getting piles of compiler errors in my app when I include the following files:
CEGUI/CEGUI.h
CEGUI/GUIContext.h
The first errors for each are "/usr/include/cegui-0/CEGUI/PropertyHelper.h|432|error: expected unqualified-id before numeric constant" and "/usr/include/cegui-0/CEGUI/SystemKeys.h|39|error: expected identifier before numeric constant" respectively.
I'm running Gentoo Linux, CEGUI 0.8.4, gcc-4.7.3, Code::Blocks 13.12, in case any of that is relevent.
I'm still trying to get a simple window to display on the screen, and I'm getting stumped. It's going to be something simple I'm getting wrong, but I can't see what it is.
I think the problem may be with the order of your include files and whatever other lib your building against. So try moving header files that reference Xlib to before/after the CEGUI includes, e.g: in GLFW3:
Code: Select all
#define GLFW_EXPOSE_NATIVE_X11
#define GLFW_EXPOSE_NATIVE_GLX
# include <GLFW/glfw3.h>
# include <GLFW/glfw3native.h>
# include <CEGUI/CEGUI.h>
# include <CEGUI/GUIContext.h>
would become:
Code: Select all
# include <CEGUI/CEGUI.h>
# include <CEGUI/GUIContext.h>
#define GLFW_EXPOSE_NATIVE_X11
#define GLFW_EXPOSE_NATIVE_GLX
# include <GLFW/glfw3.h>
# include <GLFW/glfw3native.h>
Re: Begginer Issue: Errors compiling with CEGUI headers
Ident wrote:Please post the specific line of code (in code tags) where the error occurs. This might help identify the issue.
Unfortunately I dont use the same OS or tools to reproduce this. Also I have never encountered such an error. Strange.
I *really* doubt that quoting lines of CEGUI headers will help, as no-one else seems to have this issue, but here you go:
My code (I really don't have any CEGUI calls in the file, they're all commented out to try to pin down this problem):
Code: Select all
#include <CEGUI/CEGUI.h>
Code the compiler yells at me about (From CEGUI's PropertyHelper.h):
Code: Select all
template<>
class CEGUIEXPORT PropertyHelper<bool>
{
public:
typedef bool return_type;
typedef return_type safe_method_return_type;
typedef const bool pass_type;
typedef const String& string_return_type;
static const String& getDataTypeName()
{
static String type("bool");
return type;
}
static return_type fromString(const String& str)
{
return (str == True || str == "True");
}
static string_return_type toString(pass_type val)
{
return val ? True : False;
}
//! Definitions of the possible values represented as Strings
>>> static const CEGUI::String True;
static const CEGUI::String False;
};
Error:
Code: Select all
error: expected unqualified-id before numeric constant
I tried moving the CEGUI includes around in the include order, but it didn't solve the issue.
Here's all the includes I'm using in that file, in order loaded, in case it helps (they aren't all in the same file, I went through and manually expanded the include lists from included files):
Code: Select all
#define GLEW_STATIC
#include <GL/glew.h>
#include <GL/glu.h>
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <GL/glx.h>
#include <string>
#include <vector>
#include <event2/bufferevent.h>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/version.hpp>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <map>
#include<stdio.h>
#include<stdlib.h>
#include<X11/X.h>
#include<X11/Xlib.h>
#include<X11/XKBlib.h>
#include<X11/Xutil.h>
#include <list>
#include <boost/thread.hpp>
#include <functional>
#include <boost/date_time.hpp>
#include <cstdio>
Does anything jump out at you there as a problem? I've tried including CEGUI top, bottom and several places in the middle, haven't found one that works.
Update Edit: I also tried including CEGUI in a much smaller file with nothing but the boost networking includes, and it doesn't seem to complain there, so you're right, it *IS* the include order, I just have no clue where to put CEGUI in that list to make it work.
Re: Begginer Issue: Errors compiling with CEGUI headers
It is really hard to tell what the right order is in such cases (and sometimes there is none=. You may found out sooner or later but no real benefit is gained from going that router. So here is what I do, which has always worked for me:
In my projects I try not to mix headers of different libraries in a single file if possible. I avoid this by using "managers". There is of course other way to do achieve this. Typically I would create a couple of members in my main application that resemble Managers managing certain parts of my program and which can communicate between each other if necessary (you must use forward declarations!). For example all things regarding CEGUI (input injections, updates, initialisation) are in my CEGUIManager. Additionally I use a GUIManager which is the only class that deals with the CEGUI windows and events (one should probably create a manager per Interface mode, so it stays overlookable). Since managers can be forward declared, you dont need to include everything into every header everywhere and can keep inclusions to the cpps. This typically prevents any such issues from appearing. There is no real other solution to some of the issues, it is simply due to the fact that some libraries dont like being included in certain ways, dont like being included multiple times, or redefine global variables used also in other libraries, etc etc etc. It is just a mess. Additionally, having some sort of decoupling in duties is a way to keep your code clean, readable and maintainable, which is also a huge reason for me to do this.
I would suggest you go for an approach similar to what I mentioned.
In the past I have had issues with fbx headers, a number of windows headers, glfw, and some no-name libraries, and the best solution was always to keep the headers (especially the ugly windows-headers! seriously microsoft what have you done!) segregated.
The only downside is that to be fully isolating the headers, you will need to create the Managers on the heap. The functions and members in the Managers will probably require some library-dependant types, which often might not be forward-includable. If they are, then they can be on the stack, of course.
In my projects I try not to mix headers of different libraries in a single file if possible. I avoid this by using "managers". There is of course other way to do achieve this. Typically I would create a couple of members in my main application that resemble Managers managing certain parts of my program and which can communicate between each other if necessary (you must use forward declarations!). For example all things regarding CEGUI (input injections, updates, initialisation) are in my CEGUIManager. Additionally I use a GUIManager which is the only class that deals with the CEGUI windows and events (one should probably create a manager per Interface mode, so it stays overlookable). Since managers can be forward declared, you dont need to include everything into every header everywhere and can keep inclusions to the cpps. This typically prevents any such issues from appearing. There is no real other solution to some of the issues, it is simply due to the fact that some libraries dont like being included in certain ways, dont like being included multiple times, or redefine global variables used also in other libraries, etc etc etc. It is just a mess. Additionally, having some sort of decoupling in duties is a way to keep your code clean, readable and maintainable, which is also a huge reason for me to do this.
I would suggest you go for an approach similar to what I mentioned.
In the past I have had issues with fbx headers, a number of windows headers, glfw, and some no-name libraries, and the best solution was always to keep the headers (especially the ugly windows-headers! seriously microsoft what have you done!) segregated.
The only downside is that to be fully isolating the headers, you will need to create the Managers on the heap. The functions and members in the Managers will probably require some library-dependant types, which often might not be forward-includable. If they are, then they can be on the stack, of course.
CrazyEddie: "I don't like GUIs"
Re: Begginer Issue: Errors compiling with CEGUI headers
The CEGUI code should perhaps be updated to remove the ambiguity for None/NONE and X11 . Sorry I don't have all the headers, are you sure you moved all X11 related libs including glx to the end?
Code: Select all
#define GLEW_STATIC
#include <GL/glew.h>
#include <GL/glu.h>
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
/// #include <GL/glx.h> <----- compiler errors
# include <CEGUI/PropertyHelper.h>
# include <CEGUI/SystemKeys.h>
# include <CEGUI/Window.h>
# include <CEGUI/BasicImage.h>
# include <CEGUI/ImageManager.h>
# include <CEGUI/ImageFactory.h>
# include <CEGUI/RendererModules/OpenGL/GL3Renderer.h>
# include <CEGUI/RendererModules/OpenGL/GLRenderer.h>
# include <CEGUI/RendererModules/OpenGL/Texture.h>
# include <CEGUI/CEGUI.h>
# include <CEGUI/System.h>
# include <CEGUI/SchemeManager.h>
# include <CEGUI/Singleton.h>
# include <CEGUI/WindowManager.h>
# include <CEGUI/UDim.h>
# include <CEGUI/DefaultResourceProvider.h>
#include <GL/glx.h>
#include<X11/X.h>
#include<X11/Xlib.h>
#include<X11/XKBlib.h>
#include<X11/Xutil.h>
#define GLFW_EXPOSE_NATIVE_X11
#define GLFW_EXPOSE_NATIVE_GLX
# include <GLFW/glfw3.h>
# include <GLFW/glfw3native.h>
Re: Begginer Issue: Errors compiling with CEGUI headers
dermont wrote:The CEGUI code should perhaps be updated to remove the ambiguity for None/NONE and X11 .
Please be more specific. Which "None" are we talking about?
CrazyEddie: "I don't like GUIs"
Re: Begginer Issue: Errors compiling with CEGUI headers
Ident wrote:dermont wrote:The CEGUI code should perhaps be updated to remove the ambiguity for None/NONE and X11 .
Please be more specific. Which "None" are we talking about?
Code: Select all
/media/sdb5/Libraries/OGRE/sdk/v1-9/include/cegui-0/CEGUI/SystemKeys.h:39:9: error: expected identifier before numeric constant
None = 0x0000,
X.h
#ifndef None
#define None 0L /* universal null resource or null atom */
#endif
Code: Select all
/media/sdb5/Libraries/OGRE/sdk/v1-9/include/cegui-0/CEGUI/PropertyHelper.h:437:32: error: expected unqualified-id before numeric constant
static const CEGUI::String True;
^
/media/sdb5/Libraries/OGRE/sdk/v1-9/include/cegui-0/CEGUI/PropertyHelper.h:438:32: error: expected unqualified-id before numeric constant
static const CEGUI::String False;
Xlib.h
#define True 1 <------
#define False 0 <---------
#define Bool int
#define Status int
Other libs have similar problems with Bool/Status .
Re: Begginer Issue: Errors compiling with CEGUI headers
Thanks. I will add it to the issue tracker and look into it soon. It might be, however, that we can't change this in v0-8 due to ABI compatibility.
CrazyEddie: "I don't like GUIs"
Re: Begginer Issue: Errors compiling with CEGUI headers
Spoke too soon, having to move more stuff out of the way.
Edit: Compiling now, Thanks.
Had to hide mose of XLib inside the manager implementation file, but I should be able to continue from here.
Again, Thank you for the help
Edit: Compiling now, Thanks.
Had to hide mose of XLib inside the manager implementation file, but I should be able to continue from here.
Again, Thank you for the help
Re: Begginer Issue: Errors compiling with CEGUI headers [SOL
If you manage to remove all problems, give us a short outline of what you did, this might help other users and also maybe helps us fix the issues.
CrazyEddie: "I don't like GUIs"
Re: [SOLVED]Begginer Issue: Errors compiling with CEGUI head
Sure, I can do that.
I had to add two new classes to my project: XWindowManager, and UIEvent.
XWindowManager.cpp is the only place I include any XLib headers, as the important ones argue with the CEGUI headers, and I probably need to handle CEGUI parts from program logic.
XWindowManager.h forward declares a class called XData, which is defined inside XWindowManager.cpp, to contain all the X Windows datatypes needed. XWindowManager's only members are a pointer to to an XData, and a UIEvent. (If I could add private members to a class inside it's .cpp file, the entire contents of XData would be private members of XWindowManager, but I can't, hence the pointer-to-private-members-struct hack (I'm sure there's a better name for this))
UIEvent is conceptually a reimplementation of XEvent without using X11/Xlib.h (which is where XEvent is defined). I handle holding the event details differently, but it's the same data, at least in concept (I probably throw away a lot of stuff I'm not caring about).
I *can* post the three files here if that would be clearer? (UIEvent is currently header-only)
(Edit: I'm now getting an issue where CEGUI only renders on my first frame, but that's probably better in it's own topic)
I had to add two new classes to my project: XWindowManager, and UIEvent.
XWindowManager.cpp is the only place I include any XLib headers, as the important ones argue with the CEGUI headers, and I probably need to handle CEGUI parts from program logic.
XWindowManager.h forward declares a class called XData, which is defined inside XWindowManager.cpp, to contain all the X Windows datatypes needed. XWindowManager's only members are a pointer to to an XData, and a UIEvent. (If I could add private members to a class inside it's .cpp file, the entire contents of XData would be private members of XWindowManager, but I can't, hence the pointer-to-private-members-struct hack (I'm sure there's a better name for this))
UIEvent is conceptually a reimplementation of XEvent without using X11/Xlib.h (which is where XEvent is defined). I handle holding the event details differently, but it's the same data, at least in concept (I probably throw away a lot of stuff I'm not caring about).
I *can* post the three files here if that would be clearer? (UIEvent is currently header-only)
(Edit: I'm now getting an issue where CEGUI only renders on my first frame, but that's probably better in it's own topic)
Who is online
Users browsing this forum: No registered users and 12 guests