Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!ogicse!ucsd!hub.ucsb.edu!fir!murat From: murat@fir.ucsb.edu (Karaorman, Murat) Newsgroups: comp.lang.eiffel Subject: Re: C and Eiffel ? (A correction) Message-ID: <12109@hub.ucsb.edu> Date: 18 Jun 91 21:20:10 GMT References: <702@mailgzrz.tu-berlin.de> <12051@hub.ucsb.edu> Sender: news@hub.ucsb.edu Reply-To: murat@cs.ucsb.edu (Murat Karaorman) Organization: University of California, Santa Barbara Lines: 70 In my previous posting, <12051@hub.ucsb.edu>, about calling Eiffel routines from C, I just noticed that I have overlooked an important (yet obvious) mistake that was in the original documentation. I had stated it in words: >2.1) In this C program you shouldn't use eif_rout ( ... ) to invoke a > method, but instead obtain a function pointer to the method and then > invoke the method via this pointer. You can look at the example I give. but forgotten to include in the example. Here the type of eif_rout() needs to be a function pointer, namely ROUT_PTR, as opposed to the type DATUM in the original article, therefore the example program should read: ==============================test.c======================================= #include "/cad01/Eiffel/files/_eiffel.h" #include >> #include " ... rename.h " >> #include " ... Eiffel_rout.h" extern OBJPTR eif_create (); << extern DATUM eif_rout(); >> extern ROUT_PTR eif_rout (); extern int eif_attr (); << int test () >> main () { OBJPTR obj; >> ROUT_PTR f_ptr; >> my_name_eiffel_init(); obj = eif_create("string",(DATUM) 10); >> f_ptr = eif_rout (obj, "append"); >> (* f_ptr)(obj, MakeStr("Hello world")); << eif_rout(obj, "append", MakeStr("Hello world")); printf("Size of Eiffel string is: %d\n",(int32) eif_attr (obj, "size")); return 25; } =================================end==================================== The lines starting with >> are my insertions, The lines starting with << were in your original, they need to be removed, The rest is unchanged (except for inserting DATUM) from your original. Sorry for any inconvenience this may have caused. Murat Karaorman, > >I hope this helps. Let me know if anything goes wrong. It has been a while >now, but I know that this stuff should eventually work. > >good luck, > >-----------------------------------------------------------------------------. >| Two men say they're Jesus... | >| One of them must be wrong. | >| -Dire Straits "Industrial Disease" from Love Over Gold | ------------ Two men say they're Jesus... ----. | One of them must be wrong. | | -Dire Straits | `---- murat@cs.ucsb.edu -------------------------'