g++ bug in dllexport (on windows)
Mumit Khan
khan@NanoTech.Wisc.EDU
Mon Apr 24 10:39:00 GMT 2000
Marat Boshernitsan <maratb@cs.Berkeley.EDU> writes:
>
> The following snippet of code causes an "interesting" error message on
> win32:
>
> ---- cut ----
>
> #define DLLIMPORT __attribute__(( dllexport ))
>
> class DLLIMPORT NODE {
> class DLLIMPORT Property {
> friend class NODE;
> };
> };
>
> class DLLIMPORT UltraRoot : public NODE {
> public:
> void UltraRoot::tree_size (const NODE *node = __null) const {
> const NODE *tmp = node ? node : this;
> }
> };
>
> ---- cut ----
>
> compiling with "g++ -c -o bug.o bug.cc" yields:
>
> bug.cc:12: type `const NODE' is not a base type for type `const NODE'
> bug.cc:12: type `const NODE' is not a base type for type `const UltraRoot'
>
> Doesn't make much sense, does it?
>
> Undefining DLLIMPORT fixes the error.
>
> Removing "friend class NODE" fixes the error.
Ah, this is a tricky one, and it has to do with how GCC uses attributes such
as dllimport/dllexport/etc.
I have yet to take a close look at this issue to understand what is really
going on, but you can always do the following:
class DLLIMPORT NODE {
class DLLIMPORT Property {
friend class DLLIMPORT NODE;
// ^^^^^^^^^
};
};
Regards,
Mumit
ps: the preferred bug reporting list is gcc-bugs@gcc.gnu.org, not
gcc@gcc.gnu.org, which is the "general" gcc list.
More information about the Gcc
mailing list