comp.lang.ada
 help / color / mirror / Atom feed
* Help with some Code problems using C Interface
@ 2000-04-14  0:00 Eric Bresie
  2000-04-14  0:00 ` Ted Dennison
  2000-04-25  0:00 ` Erik Schalin
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Bresie @ 2000-04-14  0:00 UTC (permalink / raw)


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>





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2000-04-25  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2000-04-25  0:00   ` David Starner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox