llothar wrote:
On 15 Mrz., 06:59, Chris Dollin <chris.dol...@hp.comwrote:
>llothar wrote:
When i use -W4 on visual c 7.0 i get warning C4054
translator1.c(1703) : warning C4054: 'type cast' : from function
pointer 'void * (__cdecl *)(se_agent *)' to data pointer 'void *'
translator1.c(1703) : warning C4152: nonstandard extension, function/
data pointer conversion in expression
whenever i cast a function pointer to a void* or back.
Is there any reason for this warning ? Looks like good C code for me.
It isn't. Function pointers and object pointers in C are not interchangable.
--
Chris "electric hedgehog" Dollin
"Life is full of mysteries. Consider this one of them." Sinclair, /Babylon 5/
(you're supposed to snip signatures: I left mine in here to show
what it was you shouldn't do ...)
But what's with function arguments casting?
You mean function /pointer/ casting.
Is it leagal to do cast two methods
(fx:snip)
So long as when you call a function through a pointer of type PF
that function really is of type PF, you're OK. You /have/ to cast
to convert a function pointer from one type to another.
Otherwise it would be extremely difficult to provide a ANSI-C eiffel
generator.
Perhaps. But such a compiler could be documented to rely on features
outside the ANSI standard, if they were widely available.
I have an written-in-C interpreter for a programming language which
we'll call X for the sake of convenience. In it's current state,
the interpreter assumes that there's an integer type T of at least
32 bits to which pointers to a structy type can be freely cast and
recovered, and what's more that there's room in that pointer and
integer for two "spare" bits.
The code won't port to a target where that's not true. [It would be
an interesting exercise to work out how it could be revised to remove
that assumption without loss of efficiency.] Fortunately I didn't
expect to port to any such target (and the code is essentially
dead now, although it may still bear children).
--
Chris "shuddering at the image" Dollin
"I'm still here and I'm holding the answers" - Karnataka, /Love and Affection/