From -6059483574120679066
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,3b852614b232b53b
X-Google-Attributes: gidf78e5,public
From: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Subject: function pointer types(was: Re: atexit() behavior)
Date: 1998/12/01
Message-ID: <3663B9D8.283B0424@physik.tu-muenchen.de>#1/1
X-Deja-AN: 417435390
X-Nntp-Posting-Host: coulomb.t30.physik.tu-muenchen.de
Content-Transfer-Encoding: 7bit
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <365f3482.0@10.1.1.65> <73vc1v$5oe$1@nnrp1.dejanews.com> <fneilYAeA0Y2Ewh7@robinton.demon.co.uk>
Content-Type: text/plain; charset=us-ascii
Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany)
Mime-Version: 1.0
Newsgroups: comp.std.c++
Originator: clamage@taumet


Francis Glassborow wrote:

[...]

> I think they have different signatures because the parameters are:
> 
> pointer to extern "C" function
> and
> pointer to extern "C++" function
> 
> and these types are differentiable.

Does that mean that I can do

bool is_c_function(void(*)()) { return false; }
extern "C"
{
  bool is_c_function(void(*)()) { return true; }
}

and use that to differentiate between C and C++ functions?

BTW, is there (in any direction) an automatic conversion between
C and C++ function pointers?
That is, is any of the following initialisations allowed?

extern "C" { typedef void (*c_ptr)(); }
typedef void (*cpp_ptr)();

extern "C" void f();
void g();
void h() throw();

cpp_ptr p1 = &f; // allowed?
c_ptr   p2 = &g; // allowed?
c_ptr   p3 = &h; // allowed?


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




