🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #38372

Re: C++ and callbacks

#38372
From: Glenn Pinkerton
Date: Tue, 03 May 1994 19:41
28 lines
2236 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.
>
>-- 

    The callback function really should be an "extern C" function if
you want portability among current and possible future C++ compilers.
Remember, C++ and C are different languages.  There is nothing in the
definition of C++ that requires that a C++ compiler use the same 
methods for passing function parameters as are used by C.  The exception
is for an "extern C" function.

Glenn Pinkerton
glp@csn.org
Technical Details
Message-ID: <Cp8s1L.M9D@csn.org>
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!hookup!swrinde!sdd.hp.com!col.hp.com!csn!glp
References: <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-03 12:48:26 PST
Newsgroups: comp.windows.x,comp.lang.c++,gnu.g++.help
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!hookup!swrinde!sdd.hp.com!col.hp.com!csn!glp
From: glp@teal.csn.org (Glenn Pinkerton)
Subject: Re: C++ and callbacks
Message-ID: <Cp8s1L.M9D@csn.org>
Sender: news@csn.org (The Daily Planet)
Nntp-Posting-Host: teal.csn.org
Organization: Colorado SuperNet, Inc.
References: <pauld.767898877@sarge> <2q65gv$oln@bigblue.oit.unc.edu> <2q67fpINNgv5@eccdb1.pms.ford.com>
Date: Tue, 3 May 1994 19:41:45 GMT
Lines: 29