🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14787

Problems with pointer to function

#14787
From: Chris
Date: Sun, 03 Aug 2003 05:14
23 lines
2083 bytes
I have a function that takes a parameter (a pointer to a function).
The function type is void (*Callback)(void*,UINT)
More specifically, RegisterMessage(void (*Callback)(void*,UINT))
I code other functions based on void (*Callback)(void*,UINT) and use
RegisterMessage(&FunctionName)

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)'

Trying to use RegisterMessage(void (* (_closure )(void *,unsigned int))(void
*,unsigned int)) didn't resolve it. I'm wondering if it would be safe to
just typecast it, or if the function is somehow different because its
declared inside a class, and therefor it would be very dangerous to typecast
it?

I'd rather not have to typecast it every time I use it, and I'd like it to
not give errors with either in and out of class functions used as parameters
in calling this function.

Please help,
Thanks.
Technical Details
Message-ID: <3f2c9a2b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!news-xfer.cox.net!peer01.cox.net!cox.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,b4f3349839697d82,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-02 22:16:27 PST
From: "Chris" <Chris8852@adelphia.net>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Problems with pointer to function
Date: Sun, 3 Aug 2003 01:14:18 -0400
Lines: 25
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.1165
NNTP-Posting-Host: 68.65.164.124
Message-ID: <3f2c9a2b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059887659 68.65.164.124 (2 Aug 2003 22:14:19 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!news-xfer.cox.net!peer01.cox.net!cox.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail