Please explain a gcc weirdness
Thiago Macieira
thiago at kde.org
Wed Jun 23 21:59:42 BST 2010
Em Quarta-feira 23. Junho 2010, às 21.28.09, Sebastian Trüg escreveu:
> Why does the following code fail with gcc 4.3.4:
>
> QString uri...;
> Nepomuk::Resource res( KUrl( uri ) );
>
> while this works:
>
> KUrl resourceUri( uri );
> Nepomuk::Resource res( resourceUri );
>
> And by "fail" I mean that gcc does not recognize res as being of type
> Nepomuk::Resource.
Because it's not of that type.
> I would simply like to understand this.
Despite what you might think, when you wrote:
Nepomuk::Resource res( KUrl( uri ) );
you didn't declare an object of type Nepomuk::Resource called "res" and call
its constructor with a KUrl parameter.
You declared an external function (the "extern" keyword is optional) called
res that returns Nepmuk::Resource.
This is correct behaviour.
It's just one of those things that bite you once, then you remember forever.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20100623/12618fc5/attachment.sig>
More information about the kde-core-devel
mailing list