red floyd wrote:[color=blue]
> Pete Becker wrote:
>[color=green]
>> red floyd wrote:
>>[color=darkred]
>>>
>>>
>>> The only options I can see are either a C-style cast to void* (unsafe
>>> and ugly),
>>>[/color]
>>
>> There's nothing unsafe about it, although it's possible (but unlikely)
>> that it won't give you useful information. On POSIX-conformant
>> platforms it's well defined.
>>[/color]
>
> I thought the Standard said something about function pointers being cast
> to void*? Hence the comment about "unsafe".[/color]
Standard C++ doesn't allow converting a function pointer into a void*.
That doesn't mean it's "unsafe." It only means that if your compiler
allows it (which every one I use does) you might want to check the
compiler's documentation to see what it does. But any compiler that
doesn't do the obvious thing is seriously freaky.
[color=blue]
>
> I know g++ 3.2.3 gives me a warning when I use either static_cast or
> reinterpret-cast.
>[/color]
Yes, that's what the standard requires. Having issued a diagnostic, the
compiler is free to do whatever the implementor chooses. If you were
writing a compiler and wanted to implement explicit conversions from
function pointers to void pointers, what would you do? (assuming the
usual architecture, where function pointers and data pointers are the
same size). There's nothing unsafe about that, is there? <g>
--
Pete Becker
Dinkumware, Ltd. (
http://www.dinkumware.com)