Article View: comp.windows.x
Article #38349Re: C++ and callbacks
From: Ian J Hogg
Date: Mon, 09 May 1994 15:45
Date: Mon, 09 May 1994 15:45
44 lines
3212 bytes
3212 bytes
In article <rfgCpG7y7.3BF@netcom.com> rfg@netcom.com (Ronald F. Guilmette) writes:
>In article <CpEBxp.9w2@news.cis.umn.edu> ianhogg@milli.cs.umn.edu (Ian J Hogg) writes:
>>In article <JASON.94May5173436@deneb.cygnus.com> jason@cygnus.com (Jason Merrill) writes:
>>>>>>>> Brandon Van Every <brandon@uncvx2.oit.unc.edu> writes:
>>>
>>>> I can't find anything in Stroustrup that says this will work. The default
>>>> linkage for all functions is "C++" (p. 524). Given that, I'd say that not
>>>> using "extern C" is rather risky.
>>>
>>>But does anything say that it won't? C and C++ use the same calling
>>>convention for plain functions, so C linkage v. C++ should have no effect
>>>on function pointers.
>>
>>Where does anything say that C and C++ use the same calling convention for
>>plain functions.
>
>In the case of fully prototyped functions, I cannot imagine any good
>reason why this should NOT be the case. Can you? If so, I would love
>to hear the reason.
>
>>As I've stated before I know of at least one compiler that
>>passes arguments for C++ linkage functions differently than C linkage functions.
>
>OK. So why don't you stop beating around the bush and tell us which compiler
>you are referring to. (You don't expect us just to take you word for it
>do you??)
>
It was the Zortech compiler for SYSV/386. I don't know if their DOS compiler
or the current Symantec compilers are implemented the same way or not. They
claimed the C++ linkage was faster. I personally feel that it was another
in a long line of bone-headed moves made by Zortech.
I have had problems with other compilers too with regard to parameter passing.
I had the "luxery" of using the Oregon C++ compiler way back in 1990. They
passed float params directly on the stack using sizeof(bytes). This caused
problems when calling functions compiled with the vendors native C compiler.
I had a "C" library from HP that one parameter of type float. When this
function was called from Oregon C++ the program died because of the mismatched
calling conventions.
--
===============================================================================
Ian Hogg ianhogg@cs.umn.edu
(612) 424-6332
Technical Details
Message-ID:
<CpJL59.KqL@news.cis.umn.edu>Path:
arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!hookup!swrinde!gatech!news-feed-2.peachnet.edu!umn.edu!milli!ianhoggReferences:
<JASON.94May5173436@deneb.cygnus.com> <CpEBxp.9w2@news.cis.umn.edu> <rfgCpG7y7.3BF@netcom.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-09 08:55:47 PST Newsgroups: comp.windows.x,comp.lang.c++,gnu.g++.help Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!hookup!swrinde!gatech!news-feed-2.peachnet.edu!umn.edu!milli!ianhogg From: ianhogg@milli.cs.umn.edu (Ian J Hogg) Subject: Re: C++ and callbacks Message-ID: <CpJL59.KqL@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: <JASON.94May5173436@deneb.cygnus.com> <CpEBxp.9w2@news.cis.umn.edu> <rfgCpG7y7.3BF@netcom.com> Date: Mon, 9 May 1994 15:45:38 GMT Lines: 44