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=0.1 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,HK_RANDOM_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a5e:d618:: with SMTP id w24mr19327018iom.164.1553532133457; Mon, 25 Mar 2019 09:42:13 -0700 (PDT) X-Received: by 2002:a9d:6a43:: with SMTP id h3mr10478437otn.270.1553532133158; Mon, 25 Mar 2019 09:42:13 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!w126no28705ita.0!news-out.google.com!l81ni50itl.0!nntp.google.com!w126no28703ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 25 Mar 2019 09:42:12 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2600:1700:13b0:9e10:f123:54d6:ff6e:b46c; posting-account=2uAEJgoAAAB3eDGmRGb1gie2cncsaATT NNTP-Posting-Host: 2600:1700:13b0:9e10:f123:54d6:ff6e:b46c References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6ffc660f-07a5-4f07-95ad-8abec510b00b@googlegroups.com> Subject: Re: differences between Ada and C in gnat forcing me to use C instead of Ada From: matthewbrentmccarty@gmail.com Injection-Date: Mon, 25 Mar 2019 16:42:13 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:55956 Date: 2019-03-25T09:42:12-07:00 List-Id: 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 tri= ed: nul_sane_device_ptr : constant Sane_Device_Ptr :=3D null; devices : aliased Device_Array (1..5) :=3D (others =3D> nul_sane_device_p= tr ); 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 =3D 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 sa= ys: 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 termin= ated array of pointers to SANE_Device structures in *device_list. The retur= ned 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. T= his function can be called repeatedly to detect when new devices become ava= ilable. If argument local_only is true, only local devices are returned (de= vices directly attached to the machine that SANE is running on). If it is f= alse, the device list includes all remote devices that are accessible to th= e 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 whi= ch would make it unnecessary and undesirable to call this function first.= =20