Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: Can extern "C" functions throw exceptions
Date: Thu, 16 Dec 2021 04:29:28 -0800
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <86ilvo4tsn.fsf@linuxsc.com>
References: <20210912144443.a174f80b419b5694959f26d9@cvine--nospam--.freeserve.co.uk> <86a6jlrjyd.fsf@linuxsc.com> <9106335c-2f48-4735-8c69-2b829fc450ccn@googlegroups.com> <868rwm6adq.fsf@linuxsc.com> <2014666f-87aa-4eb6-8fc0-f0d0addd5011n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="e672fb9610cb67396dff88ffd2617ec0"; logging-data="11986"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qQlqNs/tGzENL+l7xgVs5FCaDh6fO6RI="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:r3w1oCWZ0ypToNWLx4i+XmN4PfQ= sha1:+bP6Ax1yuy1SIkTp5cZM5hEI2kI=
Xref: csiph.com comp.lang.c++:82655
"james...@alumni.caltech.edu" writes:
> On Tuesday, December 14, 2021 at 6:21:38 PM UTC-5, Tim Rentsch wrote:
>
>> "james...@alumni.caltech.edu" writes:
>
> ...
>
>>> The language linkage of a function's type is indeed part of that
>>> type. The language linkage of a function's name is not. The
>>> standard's description of language linkage in 9.11p1 starts with
>>> the sentence "All function types, function names with external
>>> linkage, and variable names with external linkage have a
>>> language linkage.", clearly making the point that the language
>>> linkage of a function's type is a distinct thing from the
>>> language linkage of a function's name. The standard could have
>>> inextricably linked them together - but it does not. In fact,
>>> 9.11p5 includes an example demonstrating how they can be
>>> separated:
>>>
>>> extern "C" typedef void FUNC();
>>> FUNC f2; // the name f2 has C ++ language linkage and the
>>> // function?s type has C language linkage
>>>
>>> [...]
>>
>> Thank you for this citation. It doesn't answer all my questions
>> but it certainly does provide an illuminating example.
>
> If you can figure out words to express your remaining questions,
> I'd be curious to find out what they are.
At this point I'm not sure what the other questions are. And since
I don't have any way to test various scenarios (or at least not any
convenient way), for now it seems best just to stop here.
>> It appears, however, that in practice there is no difference
>> between a type with a C language linkage and a C++ language
>> linkage. Apparently most compilers ignore the distinction
>> because following the rules would break too much code. Here
>> is a link to stackoverflow with more information:
>>
>> https://stackoverflow.com/questions/26647259/
>> is-extern-c-a-part-of-the-type-of-a-function
>
> The standard is quite clear: "Two function types with different
> language linkages are distinct types even if they are otherwise
> identical." (9.11p1). [...]
Yes, I think that very sentence was quoted in the stackoverflow
page.