Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Initializers containing function names Message-ID: <1990Mar13.174517.14634@utzoo.uucp> Organization: U of Toronto Zoology References: <383@latvax8.lat.oz> Date: Tue, 13 Mar 90 17:45:17 GMT In article <383@latvax8.lat.oz> MICPRF@latvax8.lat.oz writes: >My cc compiler complains about illegal initialization if an attempt is >made to include a function name in an initializer... > >int dummy(){}; >int address = (int) dummy; > >In the S code this type of thing is embedded in arrays of structures, for >the hash tables but the problem seems to come down to the above... The problem may be the cast rather than the use of the function name. Through what seems to have been an accidental oversight, casts were not on the list of compile-time operators in K&R1, and some compilers have faithfully perpetuated this mistake. (Casting a function pointer to int is also a very machine-dependent operation, which may not give meaningful results, but that's a different issue.) -- MSDOS, abbrev: Maybe SomeDay | Henry Spencer at U of Toronto Zoology an Operating System. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu