DRAFT document on coding conventions in kde libraries

Thiago Macieira thiago at kde.org
Mon Mar 6 15:45:03 GMT 2006


Frerich Raabe wrote:
>On Monday 06 March 2006 15:12, André Wöbbeking wrote:
>> On Monday 06 March 2006 14:57, Frerich Raabe wrote:
>> > On Monday 06 March 2006 14:33, Frans Englich wrote:
>> > > Could you give an example of when one would have to use a C-style
>> > > cast?
>> >
>> > When casting the pointer returned by dlsym to the correct type, for
>> > example.
>>
>> reinterpret_cast<>() doesn't work in this case?
>
>No.

that's weird...
$ cat test.cpp
#include <dlfcn.h>

typedef void (*functype)(int, int);

main()
{
    void *sym = dlsym(0, 0);

    functype f = reinterpret_cast<functype>(sym);
    f = reinterpret_cast<void (*)(int, int)>(sym);

    (*f)(1,2);
}
$ g++ -c -o test.o test.cpp
[no errors]

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

1. On frumscafte, hwonne time_t wæs náht, se scieppend þone circolwyrde 
wundorcræftlíge cennede and seo eorðe wæs idel and hit wæs gód.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060306/86e906eb/attachment.sig>


More information about the kde-core-devel mailing list