Discussion:
[Opensg-users] OpenSG 2.0: Conflict Between X11 and Qt
Pablo Carneiro Elias
2009-05-12 14:10:40 UTC
Permalink
Hi all,

I've just updated to the last svn version of OpenSG 2.0 yesterday and I got
some compilation errors involving a conflict between X11 (included from
OSGNativeWindow.h which is included from OSGPassiveWindowBase.h) and Qt
under linux. The problem is that X11 defines many names that Qt uses as
Enums (such as KeyPress -> QEvent::KeyPress). It never happened with the
older version of OpenSG I had (dated from 2009-01-22).

Is it possible for you to remove OSGNativeWindow.h from
OSGPassiveWindowBase.h?
Or better yet, can you avoid including X11 from any public headers?

Thanks,
Pablo
Carsten Neumann
2009-05-12 14:38:28 UTC
Permalink
Hello Pablo,
Post by Pablo Carneiro Elias
I've just updated to the last svn version of OpenSG 2.0 yesterday and I
got some compilation errors involving a conflict between X11 (included
from OSGNativeWindow.h which is included from OSGPassiveWindowBase.h)
and Qt under linux. The problem is that X11 defines many names that Qt
uses as Enums (such as KeyPress -> QEvent::KeyPress). It never happened
with the older version of OpenSG I had (dated from 2009-01-22).
hm, strange, my build also picks up Qt, but it goes through fine. Can
you set -DCMAKE_VERBOSE_MAKEFILE=ON on the cmake command line, rerun
{c,}make and from the output send the compiler invocation and error
output for a file that fails?
Post by Pablo Carneiro Elias
Is it possible for you to remove OSGNativeWindow.h from
OSGPassiveWindowBase.h?
Only Gerrit can answer that, AFAIK he is in the middle of adding
something that required that, but I don't know the details.
Post by Pablo Carneiro Elias
Or better yet, can you avoid including X11 from any public headers?
I don't see how we could do that and still implement an X11Window ;)

Cheers,
Carsten
Pablo Carneiro Elias
2009-05-12 16:04:15 UTC
Permalink
Hi Carsten,

the code snippet that causes the error is this one:

line 56: if( e->type() != QEvent::KeyPress || object != ui.inputArea )
line 57: return false;

X11 define KeyPress (as a preprocessor definition) and Qt uses it as an
Enum. If I replace QEvent:KeyPress for it constant value (6), it works...

The cmake output with the gcc error on the above code is:

/src/core/ui/LuaConsoleWidget.cpp: In member function ‘virtual bool
LuaConsoleWidget::eventFilter(QObject*, QEvent*)’:
/src/core/ui/LuaConsoleWidget.cpp:56: error: expected unqualified-id before
numeric constant
/src/core/ui/LuaConsoleWidget.cpp:56: error: expected `)' before numeric
constant
make[2]: *** [src/core/CMakeFiles/siviep-core.dir/ui/LuaConsoleWidget.cpp.o]
Error 1
make[2]: *** Waiting for unfinished jobs....

Thanks,
Pablo

On Tue, May 12, 2009 at 11:38 AM, Carsten Neumann
Post by Carsten Neumann
Hello Pablo,
Post by Pablo Carneiro Elias
I've just updated to the last svn version of OpenSG 2.0 yesterday and I
got some compilation errors involving a conflict between X11 (included
from OSGNativeWindow.h which is included from OSGPassiveWindowBase.h)
and Qt under linux. The problem is that X11 defines many names that Qt
uses as Enums (such as KeyPress -> QEvent::KeyPress). It never happened
with the older version of OpenSG I had (dated from 2009-01-22).
hm, strange, my build also picks up Qt, but it goes through fine. Can
you set -DCMAKE_VERBOSE_MAKEFILE=ON on the cmake command line, rerun
{c,}make and from the output send the compiler invocation and error
output for a file that fails?
Post by Pablo Carneiro Elias
Is it possible for you to remove OSGNativeWindow.h from
OSGPassiveWindowBase.h?
Only Gerrit can answer that, AFAIK he is in the middle of adding
something that required that, but I don't know the details.
Post by Pablo Carneiro Elias
Or better yet, can you avoid including X11 from any public headers?
I don't see how we could do that and still implement an X11Window ;)
Cheers,
Carsten
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK
i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Opensg-users mailing list
https://lists.sourceforge.net/lists/listinfo/opensg-users
Carsten Neumann
2009-05-12 16:33:21 UTC
Permalink
Hello Pablo,
Post by Pablo Carneiro Elias
line 56: if( e->type() != QEvent::KeyPress || object != ui.inputArea )
line 57: return false;
oh, now I understand it, this happens somewhere in your code - was still
puzzling why I did not see this in my builds.
Post by Pablo Carneiro Elias
X11 define KeyPress (as a preprocessor definition) and Qt uses it as an
Enum. If I replace QEvent:KeyPress for it constant value (6), it works...
hm, I don't see an easy way to avoid us including <GL/glx.h> (which
drags in a bunch of X11 headers), because that would make it impossible
to have a class with members of those types - or member fields that
store the types in our case.
The only thing I can suggest immediately is to do what the boost folks
do with std::min/std::max, writing it as (std::max)(a, b) or in your case:

line 56: if( e->type() != (QEvent::KeyPress) || object != ui.inputArea )
line 57: return false;

How many instances of this kind of error are you seeing?

Cheers,
Carsten

Loading...