From: Erik Schalin <erik.schalin@emw.ericsson.se>
Subject: Re: Help with some Code problems using C Interface
Date: 2000/04/25
Date: 2000-04-25T00:00:00+00:00 [thread overview]
Message-ID: <3905C703.A7CCA7B2@emw.ericsson.se> (raw)
In-Reply-To: 38F742E3.71D536BE@arlut.utexas.edu
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
>
> <errors>
> 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
> </errors>
>
> <code>
> <ada>
> <spec>
>
> function INQUIRY (FILE : OS_CALLS.FILE_DESCRIPTOR)
> return STRING;
>
> </spec>
> <body>
> -- 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;
>
> </body>
> </ada>
> <c>
> <prototype>
> /* scsi_inquiry(file descriptor, lun, buffer, error) */
> void scsi_inquiry (int, int, char *, int *, int *);
> </prototype>
> /*
> * 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];
> }
>
> </c>
> </code>
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
next prev parent reply other threads:[~2000-04-25 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-04-14 0:00 Help with some Code problems using C Interface Eric Bresie
2000-04-14 0:00 ` Ted Dennison
2000-04-16 0:00 ` Simon Wright
2000-04-25 0:00 ` Erik Schalin [this message]
2000-04-25 0:00 ` David Starner
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox