Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!math.fu-berlin.de!mailgzrz!w203zrz!duns1222 From: duns1222@w203zrz.zrz.tu-berlin.de (Martin Dunschen) Newsgroups: comp.lang.eiffel Subject: C and Eiffel ? Message-ID: <702@mailgzrz.tu-berlin.de> Date: 6 Jun 91 18:01:34 GMT Sender: news@mailgzrz.tu-berlin.de Distribution: world Organization: TU-Berlin Lines: 135 Nntp-Posting-Host: w203zrz.zrz.tu-berlin.de Originator: duns1222@w203zrz Hello, We have a problem calling eiffel from C. We typed in the example as given in "Eiffel: The Language" Version 2.2, page 221 (but we use version 2.3 level 4) and tried to create an executable programm by adding an appropriate (?) "main.c". Of course we got errors from "ld" saying, that there are undefined symbols. Okay, so we hacked in a toy class calling this given example. Compiled with "es" everything works fine. Now we want to use this in conjunction with eiffel classes compiled to C. To get these C-versions of the system's classes we generated a C-package by changing the SDF. Is this necessary, or is there another way to use the C verions of the system classes? We ran "identify A" in the directory containing the C-routines. An archive was created. But what now? When we try to link everything together with a self written main "ld" complains about undefined symbols (eif_create, eif_rout, eif_attr, MakeStr), which we found in the archive-file in __eifc.o (most of them)! To complete the confusion we add the sources of everything as a shell-archive. Please try it and tell us, what we do wrong. P.S: The reason we want to do this, is the interfacing from prolog to eiffel, e.g. create objects, call features. The used prolog has a C interface. Thank you all for your patience !!! #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # .eiffel # neu.e # test.c # paket/my_main.c # This archive created: Thu Jun 6 19:48:11 1991 export PATH; PATH=/bin:/usr/bin:$PATH echo shar: "extracting '.eiffel'" '(477 characters)' if test -f '.eiffel' then echo shar: "will not over-write existing file '.eiffel'" else sed 's/^X//' << \SHAR_EOF > '.eiffel' X------------ EIFFEL SYSTEM DESCRIPTION FILE ------------------- X-- For simple uses, just replace ``root_class_name'' below X-- by the name of the root class of your system (lower case) XROOT: neu XUNIVERSE: $EIFFEL/library/structures $EIFFEL/library/support XEXTERNAL: test.o XNO_ASSERTION_CHECK (N): ALL XPRECONDITIONS (Y): ALL XALL_ASSERTIONS (N): ALL XDEBUG (N): XTRACE (N): XOPTIMIZE (N): ALL XGARBAGE_COLLECTION (N) XC_PACKAGE (N): paket XC_EXTERNAL: test.c XMAKE: XVISIBLE (N): neu SHAR_EOF if test 477 -ne "`wc -c < '.eiffel'`" then echo shar: "error transmitting '.eiffel'" '(should have been 477 characters)' fi fi echo shar: "extracting 'neu.e'" '(127 characters)' if test -f 'neu.e' then echo shar: "will not over-write existing file 'neu.e'" else sed 's/^X//' << \SHAR_EOF > 'neu.e' Xclass NEU Xfeature X Create is X external test : INTEGER language "C" X do X io.putint (test ()); X end; -- Create Xend -- class NEU SHAR_EOF if test 127 -ne "`wc -c < 'neu.e'`" then echo shar: "error transmitting 'neu.e'" '(should have been 127 characters)' fi fi echo shar: "extracting 'test.c'" '(341 characters)' if test -f 'test.c' then echo shar: "will not over-write existing file 'test.c'" else sed 's/^X//' << \SHAR_EOF > 'test.c' X#include "/cad01/Eiffel/files/_eiffel.h" X#include Xextern OBJPTR eif_create (); Xextern DATUM eif_rout(); Xextern int eif_attr (); Xint test () X{ X OBJPTR obj; X obj = eif_create("string", 10); X eif_rout(obj, "append", MakeStr("Hello world")); X printf("Size of Eiffel string is: %d\n",(int32) eif_attr (obj, "size")); X return 25; X} SHAR_EOF if test 341 -ne "`wc -c < 'test.c'`" then echo shar: "error transmitting 'test.c'" '(should have been 341 characters)' fi fi echo shar: "extracting 'my_main.c'" '(22 characters)' if test -f 'my_main.c' then echo shar: "will not over-write existing file 'my_main.c'" else sed 's/^X//' << \SHAR_EOF > 'my_main.c' Xmain () X{ X test (); X} SHAR_EOF if test 22 -ne "`wc -c < 'my_main.c'`" then echo shar: "error transmitting 'my_main.c'" '(should have been 22 characters)' fi fi exit 0 # End of shell archive