comp.lang.ada
 help / color / mirror / Atom feed
From: matthewbrentmccarty@gmail.com
Subject: Re: differences between Ada and C in gnat forcing me to use C instead of Ada
Date: Mon, 25 Mar 2019 09:42:12 -0700 (PDT)
Date: 2019-03-25T09:42:12-07:00	[thread overview]
Message-ID: <6ffc660f-07a5-4f07-95ad-8abec510b00b@googlegroups.com> (raw)
In-Reply-To: <c1aea932-9ae1-4915-a260-b6bc0b24c12c@googlegroups.com>

Hi all:

I don't know.  I chose 5 elements in the array since I only have 1 scanner attached to my system.  I wasn't sure how to make it null terminated. I tried:

nul_sane_device_ptr : constant Sane_Device_Ptr := null;
devices :  aliased  Device_Array (1..5) := (others => nul_sane_device_ptr );


In my C example which works, I have a header that says:

#define NELEMS(x)  (sizeof(x) / sizeof((x)[0]))
void sane_print_devices (const SANE_Device ** device_list);


and then C code which does the following:

const SANE_Device	**device_list;

status = sane_get_devices (&device_list, SANE_TRUE);
sane_print_devices (device_list);

I thought &device_list was the same as "devices(1)'Address" in Ada.

Regards,
Matthew McCarty

PS:

There's a html file at http://www.sane-project.org/html/doc012.html that says:

4.3.3 sane_get_devices

This function can be used to query the list of devices that are available. If the function executes successfully, it stores a pointer to a NULL terminated array of pointers to SANE_Device structures in *device_list. The returned list is guaranteed to remain unchanged and valid until (a) another call to this function is performed or (b) a call to sane_exit() is performed. This function can be called repeatedly to detect when new devices become available. If argument local_only is true, only local devices are returned (devices directly attached to the machine that SANE is running on). If it is false, the device list includes all remote devices that are accessible to the SANE library.

    SANE_Status sane_get_devices (const SANE_Device *** device_list,
                                  SANE_Bool local_only);

This function may fail with SANE_STATUS_NO_MEM if an insufficient amount of memory is available.

    Backend Implementation Note
    SANE does not require that this function is called before a sane_open() call is performed. A device name may be specified explicitly by a user which would make it unnecessary and undesirable to call this function first. 


  parent reply	other threads:[~2019-03-25 16:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-25  5:46 differences between Ada and C in gnat forcing me to use C instead of Ada matthewbrentmccarty
2019-03-25  5:58 ` Jere
2019-03-25  8:25 ` Dmitry A. Kazakov
2019-03-25 14:06   ` Florian Weimer
2019-03-25 10:56 ` Philip Munts
2019-03-25 11:54 ` Lucretia
2019-03-25 14:09 ` matthewbrentmccarty
2019-03-25 14:20   ` Dmitry A. Kazakov
2019-03-25 16:46     ` Jeffrey R. Carter
2019-03-25 18:01       ` Dmitry A. Kazakov
2019-03-25 17:38   ` Niklas Holsti
2019-03-25 16:42 ` matthewbrentmccarty [this message]
2019-03-25 18:18   ` Dmitry A. Kazakov
2019-04-04  0:51     ` matthewbrentmccarty
replies disabled

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