Article View: comp.std.c++
Article #1723Re: Linkage revisited
From: Warner Losh
Date: Mon, 14 Aug 1995 06:50
Date: Mon, 14 Aug 1995 06:50
50 lines
2395 bytes
2395 bytes
In article <4068ab$o58@senator-bedfellow.mit.edu>,
John Carr <jfc@mit.edu> wrote:
>Linkage is part of the type of a function (and therefore a function
>pointer type includes this information). A "C" function can be called
>just like a C++ function except for overloading and possibly default
>arguments.
I have two objections to this.
First, how do I declare a type that is a pointer to an extern "C"
function that returns void and has no args?
extern "C" { typedef void (*fp)(); }
or
typdef extern "C" void (*fp)();
The second form gives me compiler errors. I'm fairly sure that it
isn't allowed by the current grammar, the couple of quick compiler
tests show that no one accepts it.
The second is realted. This would be the only type specifier that
applies only to functions, and its expression is non-orthogonal to the
rest of the language. Since you can't easily declare these beasts, it
becomes much harder to use them.
The bottom line is that if you want to make it part of the type of a
function or a function pointer, much more work is needed on the draft
to reflect this fact. I believe you will start running into some of
the same problems that member functions:
Casting rules. Can I cast a extern "C" to C++ and back again?
Calling rules. When it is defined and undefined to make calls
through these pointers.
Size issues. Is an extern "C" pointer the same size as an
extern "C++" pointer?
I think that someone needs to go through the working paper and tighten
up these issues, since the current draft isn't as clear as it could be
on this.
None of this is to say that this is an inherently bad idea, but many
hurdles still remain before these objects are first class C++ objects.
Warner
--
Warner Losh "VMS Forever" home: imp@village.org
Cyberspace Development, Inc work: imp@marketplace.com
Makers of TIA, The Internet Adapter. http://marketplace.com/
Technical Details
Message-ID:
<MATT.95Aug13235015@physics2.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!128.32.155.1!mattReferences:
<1995Aug4.163853.11570@forte.com> <DCyD2M.46H@tigadmin.ml.com> <4068ab$o58@senator-bedfellow.mit.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt From: imp@village.org (Warner Losh) Newsgroups: comp.std.c++ Subject: Re: Linkage revisited Date: 14 Aug 1995 06:50:15 GMT Organization: The Village Approved: matt@physics2.Berkeley.EDU (Matt Austern) Message-ID: <MATT.95Aug13235015@physics2.Berkeley.EDU> References: <1995Aug4.163853.11570@forte.com> <DCyD2M.46H@tigadmin.ml.com> <4068ab$o58@senator-bedfellow.mit.edu> NNTP-Posting-Host: physics2.berkeley.edu