Article View: borland.public.cppbuilder.nativeapi
Article #14708Re: Problems with pointer to function
From: Remy Lebeau (TeamB)
Date: Sun, 03 Aug 2003 19:48
Date: Sun, 03 Aug 2003 19:48
28 lines
1891 bytes
1891 bytes
"Chris" <Chris8852@adelphia.net> wrote in message news:3f2c9a2b$1@newsgroups.borland.com... > This works fine, but when the function (FunctionName) is > declared inside a class, it gives me the error: > [C++ Error] Unit1.cpp(30): E2034 Cannot convert 'void > (* (_closure )(void *,unsigned int))(void *,unsigned int)' to > 'void (*)(void *,unsigned int)' Your register function is expecting standalone functions, not class methods. They are not the same thing. A class method has an extra 'this' pointer associated with it, thus its signature is different, as you can see by the error message. The only way to use a class method with your register function is to declare the method as static to remove the 'this' pointer. > I'm wondering if it would be safe to just typecast it No. > or if the function is somehow different because its declared > inside a class, and therefor it would be very dangerous to > typecast it? Yes Gambit
Technical Details
Message-ID:
<3f2d658a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-05!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3f2c9a2b$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,b4f3349839697d82 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-08-03 12:49:31 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f2c9a2b$1@newsgroups.borland.com> Subject: Re: Problems with pointer to function Date: Sun, 3 Aug 2003 12:48:07 -0700 Lines: 30 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3f2d658a$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1059939722 207.175.226.26 (3 Aug 2003 12:42:02 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-05!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail