Article View: comp.lang.eiffel
Article #1631Re: How to use @ with attribute?
From: Mark Summerfield
Date: Fri, 09 Mar 1990 00:15
Date: Fri, 09 Mar 1990 00:15
48 lines
2178 bytes
2178 bytes
In article <18296@cs.yale.edu< jellinghaus-robert@CS.Yale.EDU (Rob Jellinghaus) writes: < <I want to pass the address of a particular (integer) field of an object to <a C routine I've written. The class looks something like this: < <class STORED_OBJECT < ... <feature < hash_value: INTEGER; < hash is < external < hash_object(current_obj: ANY, hash_val: ANY) < language "C" < do < hash_object(Current, @hash) < end <end -- stored_object < <Pass 1 on class stored_object <... <C-compiling stored_object <"stored_object.c": line 125: unacceptable operand of & <es: C-compilation canceled < <Why is this? I had exactly the same problem- I think it's a bug in the compiler which causes it to generate incorrect C code. The C, if you look at it, attempts to cast an object structure to type integer (presumably the integer is the first field of the object structure), and then pass a pointer to the C routine (in this case hash_object). ie the C code is (effectively- it doesn't look exactly like this!) hash_object( ... , & (int) object ) I don't believe this is a legal C construct. The correct code would be: hash_object( ... , (int *) &object ) If this is a bug (and I'm prepared to be corrected, because I would like to make it work too!), you may have to work around it by actually editing the C files (yuk, blechh) but this is utterly impractical if you've got more than one or two instances of this, and completely defeats the purpose of the nice incremental build system ISE have provided us with. If you find a better solution, let me know. Mark Summerfield, Telecom Research Laboratories, Australia.
Technical Details
Message-ID:
<1159@trlluna.trl.oz>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!bionet!ames!uhccux!munnari.oz.au!bruce!trlluna!shiva!summerReferences:
<18296@cs.yale.edu<Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!bionet!ames!uhccux!munnari.oz.au!bruce!trlluna!shiva!summer From: summer@shiva.trl.oz (Mark Summerfield) Newsgroups: comp.lang.eiffel Subject: Re: How to use @ with attribute? Message-ID: <1159@trlluna.trl.oz> Date: 9 Mar 90 00:15:57 GMT References: <18296@cs.yale.edu< Sender: root@trlluna.trl.oz Reply-To: summer@shiva.trl.oz (Mark Summerfield) Organization: Telecom Research Labs., Switched Networks Research Branch Lines: 48