Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-10-10 18:05:23

----- Original Message -----
From: "George A. Heintzelman" <georgeh_at_[hidden]>

> 2) (More troublesome) in once.cpp,
> once_callback cb = reinterpret_cast<once_callback>(pthread_getspecific(k
> ey));
> fires an error, complaining that:
> /work/nova/2465/once.cpp: In function `void {anonymous}::do_once()':
> /work/nova/2465/once.cpp:41: ANSI C++ forbids casting between pointers
> to functions and objects
> This is, I think, strictly correct. It is arguably a flaw in the
> standard that a pointer to an extern "C" function cannot be converted
> back and forth with a void *, since C allows that behavior, but I could
> find nothing in the standard that excepted extern "C" functions from
> the conversion rules.

Although 'C' allows you to make that conversion, I don't think there's a
guarantee that it does anything sensible (since a function pointer is
allowed to be bigger than an object pointer). IIRC, to get the equivalent
behavior in C++ one must use reinterpret_cast<void*>(&f)


Boost list run by bdawes at, gregod at, cpdaniel at, john at