comp.lang.ada
 help / color / mirror / Atom feed
From: Eric Bresie <bresie@arlut.utexas.edu>
Subject: Help with some Code problems using C Interface
Date: 2000/04/14
Date: 2000-04-14T16:06:39+00:00	[thread overview]
Message-ID: <38F742E3.71D536BE@arlut.utexas.edu> (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>





             reply	other threads:[~2000-04-14  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-14  0:00 Eric Bresie [this message]
2000-04-14  0:00 ` Help with some Code problems using C Interface Ted Dennison
2000-04-16  0:00   ` Simon Wright
2000-04-25  0:00 ` Erik Schalin
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