Obfuscated code
David Woodman
woodman at sumax.UUCP
Tue Dec 5 19:59:24 AEST 1989
Hello,
I ran across a piece of code I am unable to decipher. I wonder if
anyone else can figure this one out.
struct MYSTRUCT someVariable;
someVariable = (*((struct MYSTRUCT *)(*)()_msg))(parameters,...);
to quote: "The effect of this bizarre construction is to typecast the
meaning of the symbol, _msg (as opposed to the value returned by the
function, _msg()), from pointer-to-function-returning-id to
pointer-to-function-returning-MYSTRUCT. This is based on the fact that
C treats names as legal expressions and therefore a valid subject for a
typecast, including even the name part of the function in an expression
calling that function."
NOTE: the called functions default to a return type of 'id'
This much I have figured out:
(*((struct MYSTRUCT *) ...
the part (*)()_msg has me stumped.
P.S. This comes out of 'Object Oriented Programming' by Brad J. Cox
Chapter 5, page 86 (ISBN0-201-10393-1)
Addison-Wesley, 1987
--
------------------------------------------------------------------------
David Woodman MAIL: woodman%sumax.uucp at beaver.cs.washington.edu
Seattle University #include <disclaimer.std>
More information about the Comp.lang.c
mailing list