Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!mit-eddie!uw-beaver!sumax!woodman From: woodman@sumax.UUCP (David Woodman) Newsgroups: comp.lang.c Subject: Obfuscated code Message-ID: <1123@sumax.UUCP> Date: 5 Dec 89 08:59:24 GMT Organization: Seattle University, Seattle, WA Lines: 32 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@beaver.cs.washington.edu Seattle University #include