Howard wrote:
"silversurfer2025" <ki****@web.dewrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hello world,
I seem to go from one tricky error to the other (at least tricky for
me). I am using qt and another code-package where many other files are
stored which I need (written by someone else). The problem is that
within this package and qt there are two definitions of the class
'Region' such that I get the compiler-error:
use of 'Region' is ambiguous
/usr/local/Trolltech/Qt-4.1.4/include/QtGui/qwindowdefs.h:124: error:
first declared as 'typedef struct _XRegion* Region' here
../../robotcontrol/src/./ImageProcessing/ObjectAnalysis/ChainCoding.h:10:
error: also declared as 'class Tribots::Region' here
I tried explicitly selecting one of the "Regions" by providing a
namespace in front of them e.g. myNameSpace::Region but it did not
work, it still tells me it would be ambiguous... What can I do in such
a situation? Apparently both classes are not written by me and I do not
want to change any of both because it would destroy a lot of
dependencies in other classes...
What's "Tribots"? A namespace? Which Region did you want? And what is it,
a type? A member?
The Tribots (namespace) Region is a class whereas the one in Qt is
'typedef struct _XRegion* Region' (simply a type-definition?)
>
I can't tell from that little information exactly what it is that you tried.
I am sorry, but what kind of code should I post? The source-Code from
Qt and the code from the other package?
>
You need to show us the code that the error message is referring to. You
should always do this when asking about an error. (See the FAQ @
http://www.parashift.com/c++-faq-lite/ . especially section 5, for what's
expected when posting questions here.)
I know the FAQ, but sometimes it is not that easy to find the right
code to post and I thought this was the right amount (even if it was
not compilable)..
>
Namespaces are indeed the proper way to isolate identical symbols from each
other, but without more information, I can't tell where (or even if) they
can be used to fix your problem.
Thanks anyway, I'll try to give more information...
OK Here we go:
-----------------------------------------------------
The Code from the Region.h:
#include <vector>
#include "../Formation/Image.h"
#include "../../Fundamental/Vec.h"
namespace Tribots {
class Region {
public:
int colClass;
inline Region(int colClass, int x, int y);
inline Region();
int getArea() const;
Vec getCenterOfGravity() const;
double getCompactness() const;
protected:
int area;
Vec centerOfGravity;
};
}
-----------------------------------------------------
ContourMeasure.h (where Region is used):
using namespace Tribots;
class ContourMeasure {
public:
static Tribots::Region* region;
};
PS: I know that there is a double use of Tribots in using namespace and
directly before the type.. This was just a try to beat the compiler
error, which apparently did not worl :(
-----------------------------------------------------
I skip the code from Qt here or should I post it as well? I guess the
line which is important is already in the error message:
/usr/local/Trolltech/Qt-4.1.4/include/QtGui/qregion.h:103: error: use
of 'Region' is ambiguous
/usr/local/Trolltech/Qt-4.1.4/include/QtGui/qwindowdefs.h:124: error:
first declared as 'typedef struct _XRegion* Region' here
.../../robotcontrol/src/./ImageProcessing/ObjectAnalysis/ChainCoding.h:10:
error: also declared as 'class Tribots::Region' here
--------------------------------------------------
Now what I do not understand is that the class ChainCoding (where the
class Region is defined) is part of another namespace as Qt, so why
does the compiler not like it? Furthermore, the error message refers to
files within Qt, so what can I do about that?
Thanks once more, hope this is enough code to make myself clear :P
Greetings and thanks a lot
Tim
PS I do not know how to put compilable code in here because this would
include Qt-Files and the other Package :(