From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fc95dcfbcc687cf9 X-Google-Attributes: gid103376,public From: Erik Schalin Subject: Re: Help with some Code problems using C Interface Date: 2000/04/25 Message-ID: <3905C703.A7CCA7B2@emw.ericsson.se>#1/1 X-Deja-AN: 615518720 Content-Transfer-Encoding: 7bit References: <38F742E3.71D536BE@arlut.utexas.edu> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: news.emw.ericsson.se 956679962 136.225.78.212 (Tue, 25 Apr 2000 18:26:02 MET DST) Organization: Ericsson Microwave Systems AB MIME-Version: 1.0 NNTP-Posting-Date: Tue, 25 Apr 2000 18:26:02 MET DST Newsgroups: comp.lang.ada Date: 2000-04-25T00:00:00+00:00 List-Id: Eric Bresie wrote: > > Okay...I am working on some ADA with some C function bindings. > > I have the following error being displayed when I compile the given code > (spec and body) with the corresponding C code > > There are a number of similar problems, but I figured I would try and > handle one since the others should be the same. > > I have included only the related code. Hopefully you can see my method > of seperating the sections....I have XML in the brain at the moment :-) > > I am sure this is a simple matter of a typo somewhere so any help would > be appreciated. > > Eric Bresie > ebresie@usa.net > > > gnatbind -aO./ -aO. -I- -x tcim1.ali > gnatlink -g tcim1.ali > ./scsi_generic.o: In function `scsi_generic__inquiry': > ./scsi_generic.adb:53: undefined reference to `scsi_inquiry' > gnatmake: *** link failed. > > Compilation exited abnormally with code 4 at Fri Apr 14 10:33:48 > > > > > > > function INQUIRY (FILE : OS_CALLS.FILE_DESCRIPTOR) > return STRING; > > > > -- scsi inquiry > -- > function INQUIRY ( > FILE : OS_CALLS.FILE_DESCRIPTOR) > return STRING > is > > procedure SCSI_INQUIRY ( > FD : INTEGER; > LUN : INTEGER; > INQ_BUFFER : SYSTEM.ADDRESS; > BYTECOUNT : SYSTEM.ADDRESS; > ERROR : SYSTEM.ADDRESS); > pragma INTERFACE (C, SCSI_INQUIRY); > pragma INTERFACE_NAME (SCSI_INQUIRY, "scsi_inquiry"); > > INQ_BUFFER : STRING (1..200); > ERROR : INTEGER; > LUN : INTEGER := 0; > CNT : INTEGER := 0; > begin > > SCSI_INQUIRY (INTEGER (FILE), -- this is line 53 of > scsi_generic.adb > LUN, > INQ_BUFFER(1)'ADDRESS, > CNT'ADDRESS, > ERROR'ADDRESS); > > return INQ_BUFFER; > > end INQUIRY; > > > > > > /* scsi_inquiry(file descriptor, lun, buffer, error) */ > void scsi_inquiry (int, int, char *, int *, int *); > > /* > * SCSI inquiry command. > */ > void > scsi_inquiry (int fd, int lun, char * buffer, int *bytecount, int * > error) > { > int i; > static unsigned char scsi_command[INQUIRY_CMD_LEN]; > > scsi_command[0] = INQUIRY_CMD; /* command */ > scsi_command[1] = (lun << LUN_OFFSET_SHIFT); /* lun/reserved > */ > scsi_command[2] = 0; /* page code */ > scsi_command[3] = 0; /* reserved */ > scsi_command[4] = INQUIRY_REPLY_LEN; /* allocation length */ > scsi_command[5] = 0; /* reserved/flag/link */ > > *error = sg_command ( > fd, > scsi_command, /* scsi command */ > INQUIRY_CMD_LEN, /* command descriptor length */ > 0, /* input buffer */ > 0, /* input size */ > buffer, /* output buffer */ > INQUIRY_REPLY_LEN); /* output size */ > > if ( *error >= 0 ) *bytecount = *error; > > for (i = 0; i < INQUIRY_REPLY_LEN - 8; i++) > buffer[i] = buffer[i+8]; > } > > > Hi Eric First question: Do you include the compiled c-file (.o)? You should use: pragma Linker_Option(filename.o); second: ONLY use small letters, NOT THE BIG ONES. I do not know the english term. Ada only produce small letters, but c mix the letters exactly as you write them. Third: check the compiler reference manual. look foor import_procedure. this might help. four: export the c-code. five: compile the c-code. use the unix command nm, to see wich procedures is visible. Maybe some of these hints will help Erik