Article View: comp.windows.x
Article #38358Re: C++ and callbacks
From: Ian J Hogg
Date: Wed, 04 May 1994 19:52
Date: Wed, 04 May 1994 19:52
29 lines
2565 bytes
2565 bytes
In article <2q67fpINNgv5@eccdb1.pms.ford.com> poorman@cc4032.pms.ford.com (Glenn M. Poorman) writes:
>In article <2q65gv$oln@bigblue.oit.unc.edu>, brandon@uncvx2.oit.unc.edu (Brandon Van Every) writes:
>|> Paul Durbin (pauld@verdix.com) wrote:
>|> : I attempt to use a member function as callback but all three arguments (to the
>|> : callback) are garbage. If I make it a friend then the arguments are correct,
>|> : but then I can't get to the class data, without reference thru an instance of
>|> : the class and I don't want the data to be static.
>|>
>|> : So, what is causing this problem?
>|>
>|> Motif is based on C, not C++. You have to use "extern C" linkage for any of
>|> your callbacks. You can't register any C++ function directly. You have to
>|> write a plain C front end for anything you want to have callbacked.
>
>Actually the function does not have to have "extern C" linkage. It just
>can't be a non-static member function.
>
Actually, the callback function should have "C" linkage. I have used a
compiler that passed arguments differently for C linkage and C++ linkage.
So, if I had a free standing function with C++ linkage and used it as a
callback function, the parameters would be messed up. This is not an issue
with most compilers but be aware it could be.
Can anyone guess the compiler in question?
--
===============================================================================
Ian Hogg ianhogg@cs.umn.edu
(612) 424-6332
Technical Details
Message-ID:
<CpAn8x.5I1@news.cis.umn.edu>Path:
arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!hookup!swrinde!cs.utexas.edu!howland.reston.ans.net!europa.eng.gtefsd.com!MathWorks.Com!news.duke.edu!news-feed-1.peachnet.edu!umn.edu!milli!ianhoggReferences:
<pauld.767898877@sarge> <2q65gv$oln@bigblue.oit.unc.edu> <2q67fpINNgv5@eccdb1.pms.ford.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103734,ad5a39011a2d3d26 X-Google-Attributes: gid103734,public X-Google-Thread: 109fba,ad5a39011a2d3d26 X-Google-Attributes: gid109fba,public X-Google-Thread: 10ba33,ad5a39011a2d3d26 X-Google-Attributes: gid10ba33,public X-Google-ArrivalTime: 1994-05-04 13:08:27 PST Newsgroups: comp.windows.x,comp.lang.c++,gnu.g++.help Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!hookup!swrinde!cs.utexas.edu!howland.reston.ans.net!europa.eng.gtefsd.com!MathWorks.Com!news.duke.edu!news-feed-1.peachnet.edu!umn.edu!milli!ianhogg From: ianhogg@milli.cs.umn.edu (Ian J Hogg) Subject: Re: C++ and callbacks Message-ID: <CpAn8x.5I1@news.cis.umn.edu> Sender: news@news.cis.umn.edu (Usenet News Administration) Nntp-Posting-Host: milli.cs.umn.edu Organization: University of Minnesota, Minneapolis, CSci dept. References: <pauld.767898877@sarge> <2q65gv$oln@bigblue.oit.unc.edu> <2q67fpINNgv5@eccdb1.pms.ford.com> Date: Wed, 4 May 1994 19:52:19 GMT Lines: 29