jl42+@andrew.cmu.edu (Jay Mathew Libove) (11/10/87)
Hello. I'm trying to compile the recently posted umoria sources on a SCO Xenix machine. In the source file "spells.c" at line 833 and line 933 I get the error: `destroy' : not a function The function "destroy" is defined in those places by being returned by the function "get_flags" as: int fire_ball(typ, dir, y, x, dam_hp, descrip) int typ, dir, y, x, dam_hp; ctype descrip; { (a bunch of local variable defines) int (*destroy)(); (some code) the get_flags call: get_flags(typ, &weapon_type, &harm_type, &destroy); (some more code) line 833: if (destroy(t_list[c_ptr->tptr.tval)) (void) delete_object(i, j); the garbage around line 933 is in the same format. Can anyone suggest to me how to get around what seems to be a limitation in my compiler? This is SCO Xenix 2.2.1 using Development System 2.1.4 on an IBM PC/AT compatible (PCs Limited AT^8) with 1.5 megs of RAM and 100 megs of hard disk; never a hardware/software incompatibility, so I'm sure it's SCO's fault :-) Thanks in advance!!! Jay Libove Arpa: jl42@andrew.cmu.edu Bitnet: jl42@drycas.bitnet UUCP: ...!{uunet, ucbvax, harvard}!andrew.cmu.edu!jl42 UUCP: ...!{pitt | bellcore} !darth!libove!libove Disclaimer: I don't tell my employers what I think... ----------------
pcng@cadlab.jmrc.eecs.unsw.oz (Po Cheung Ng) (11/13/87)
in article <AVZrt1y00VoDyUE09n@andrew.cmu.edu>, jl42+@andrew.cmu.edu (Jay Mathew Libove) says: > > Hello. I'm trying to compile the recently posted umoria sources on a > SCO Xenix machine. > > In the source file "spells.c" at line 833 and line 933 I get the > error: > > `destroy' : not a function > > The function "destroy" is defined in those places by being returned by > the function "get_flags" as: > > int fire_ball(typ, dir, y, x, dam_hp, descrip) > int typ, dir, y, x, dam_hp; > ctype descrip; > { > (a bunch of local variable defines) > int (*destroy)(); > > (some code) > the get_flags call: > get_flags(typ, &weapon_type, &harm_type, &destroy); > (some more code) > line 833: > if (destroy(t_list[c_ptr->tptr.tval)) > (void) delete_object(i, j); Try: if ((*destroy)(t_list[c_ptr->tptr.tval)) That should work ---------------- Po Cheung NG ISD: +61 2 697-5301 JMRC, School of Elec. Eng. and Comp. Sci., STD: (02) 697-5301 The University of New South Wales, FAX: +61 2 662-2087 PO Box 1, Kensington, ARPA: pcng%cad.unsw.oz@seismo.css.gov Sydney, NSW 2033, JANET: cad.unsw.oz!pxng@ukc AUSTRALIA. ACSnet: pcng@cad.unsw.oz UUCP: {enea,hplabs,mcvax,prlb2,seismo,ubc-vision,ukc}!munnari!cad.unsw.oz!pcng
chapman@sco.COM (Brian Chapman) (11/18/87)
In article <AVZrt1y00VoDyUE09n@andrew.cmu.edu> jl42+@andrew.cmu.edu (Jay Mathew Libove) writes: < Hello. I'm trying to compile the recently posted umoria sources on a < SCO Xenix machine. < < I get the error: < `destroy' : not a function < < int (*destroy)(); < (some code) < get_flags(typ, &weapon_type, &harm_type, &destroy); < (some more code) < if (destroy(t_list[c_ptr->tptr.tval)) < Can anyone suggest to me how to get around what seems to be a < limitation in my compiler? < [...] I'm sure it's SCO's fault :-) correct C is: if ((*destroy)(t_list[c_ptr->tptr.tval)) destory is a function pointer. (*destory) is a function. -- Brian Chapman uunet!sco!chapman
john@frog.UUCP (11/20/87)
In article <390@sco>, chapman@sco.COM (Brian Chapman) writes: > In article <AVZrt1y00VoDyUE09n@andrew.cmu.edu> > jl42+@andrew.cmu.edu (Jay Mathew Libove) writes: > < int (*destroy)(); > < if (destroy(t_list[c_ptr->tptr.tval)) > correct C is: > if ((*destroy)(t_list[c_ptr->tptr.tval)) > destory is a function pointer. > (*destory) is a function. This is a "common" shorthand allowed by compilers. The first form can have no other meaning, so it isn't really perverting anything. If I read it correctly, the latest ANSI C definition specifically allows the shorthand: "3.3.2.2 Function calls Constraints The expression that denotes the function called shall have type pointer to function returning void or returning an object type other than array(23). ... 23. Most often, this is the result of converting an identifier that is a function designator." N.B. "3.2.2.1 Lvalues and function designators ... A _function designator_ is an expression that has function type. ... a function designator with type "function returning _type_" is converted to an expression that has type "pointer to function returning _type_." (Myself, I've always thought that '(*destroy)' should load the code of the function into register R0... :-) -- John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101 ...!decvax!frog!john, ...!mit-eddie!jfw, jfw@eddie.mit.edu "Cutting the space budget really restores my faith in humanity. It eliminates dreams, goals, and ideals and lets us get straight to the business of hate, debauchery, and self-annihilation." -- Johnny Hart