Path: utzoo!attcan!uunet!husc6!bloom-beacon!oberon!sdcrdcf!hplabs!hpda!hpcupt1!hpcuhb!hpcllla!hpcllz2!walter From: walter@hpcllz2.HP.COM (Walter Murray) Newsgroups: comp.lang.c Subject: Re: Casting function ptrs Message-ID: <7330004@hpcllz2.HP.COM> Date: 23 May 88 15:02:12 GMT References: <281@marob.MASA.COM> Organization: HP NSG/ISD Computer Language Lab Lines: 31 chris@trantor.umd.edu (Chris Torek) writes: >In article <7330003@hpcllz2.HP.COM> walter@hpcllz2.HP.COM (Walter Murray) >writes: >>... but I think the following has the virtue of being strictly >>conforming per the dpANS. ... >> >>struct funcs {char *name; void (*func)();}; >>char *foo() {return "It worked!";}; >>struct funcs f = {"foo",(void(*)())foo}; >This is not strictly conforming, because the standard does not say >whether objects of type `void (*)()' are in any way compatible with >objects of type `char *(*)()'. (It says very little about pointers >to functions, no matter what the return type of the function....) > >Most likely, pointers to any function, no matter what the return >type, will have the same format, but it would be nice to have some >guarantees. I was relying on the following statement from page 47 of the January draft: "A pointer to a function of one type may be converted to a pointer to a function of another type and back again; the result shall compare equal to the original pointer." That sounds to me like a guarantee. Did I read too much into it? Walter Murray All opinions expressed are my own.