KDElibs/win32 merge: How to resolve followin issue..

Thiago Macieira thiago.macieira at kdemail.net
Sat Aug 28 15:58:51 BST 2004


Jarosław Staniek wrote:
>Changing return type for subclasses, e.g. in kio/kio
>(KServiceFactory : public KServiceFactory):
>
>   virtual KService * KServiceFactory::createEntry(int offset);
>
>...is not portable outside gcc world.

That's valid and correct C++ code. Specialised return types are specified in 
the C++ standard.

There's also the covariant specialised return types that g++ doesn't 
support, so you won't find in our code. But that's also valid C++ code.

>There are more places like this. 
>Originally I have just changed  KService* return type back to
> KSycocaEntry* and added static_cast<KService*> when needed (not really
> often). This is _portable_ and relatively clean (because it's a protected
> method, so no public API is affected), and binary compatible. Not ifdefs,
> and doxygen docs will remain clean.
[snip]
>Is all of this reasonable for you?

Maybe for this _one_ case it's ok. But it is not for all cases. I am 
thinking of my own code:

in KPassiveSocketBase (: public KSocketBase) we have:
	virtual KActiveSocketBase* accept() = 0;
in KSocketDevice (: public KActiveSocketBase, public KPassiveSocketBase) we 
have:
	virtual KSocketDevice* accept();
in KServerSocket (: public KPassiveSocketBase), we _should_ have:
	virtual KStreamSocket* accept();
which doesn't work in g++ because KStreamSocket's direct inheritance goes to 
QObject first then KActiveSocketBase, so it's actually
	virtual KActiveSocketBase* accept();

You are asking us to dumb down perfectly working code because one compiler 
doesn't implement the C++ standard fully. I can appreciate the problem, but 
I would rather prefer to find another solution.

It's already bad that we have to take into account g++'s own deficiencies 
(not being able to add "using" inside classes, for instance, or covariant 
return types).

Isn't there an update available for your compiler that implements those 
things?
-- 
  Thiago Macieira  -  Registered Linux user #65028
   thiago (AT) macieira (DOT) info
    ICQ UIN: 1967141   PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040828/c9f2125c/attachment.sig>


More information about the kde-core-devel mailing list