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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a77191f3e4e3079e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news.uni-jena.de!not-for-mail From: Christopher Broeg Newsgroups: comp.lang.ada Subject: Re: trying to call HDF5 from ada -- problems with constants Date: Thu, 26 Aug 2004 13:46:12 +0200 Organization: Friedrich Schiller University Jena, Germany Message-ID: References: NNTP-Posting-Host: ent.astro.uni-jena.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: fsuj29.rz.uni-jena.de 1093520772 22026 141.35.25.76 (26 Aug 2004 11:46:12 GMT) X-Complaints-To: news@rz.uni-jena.de NNTP-Posting-Date: 26 Aug 2004 11:46:12 GMT User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040114 X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:3023 Date: 2004-08-26T11:46:12+00:00 List-Id: Jeff C, wrote: > "Christopher Broeg" wrote in message > news:cgk5i0$cfu$1@fsuj29.rz.uni-jena.de... > >>What is the standard way to import C constants that are not "constant" >>from one run to the next, but derived from some "invisible" library in the >>.h files? > > > > If they really vary from one run to the next then I think you have no choice > but to build bindings to C functions that return them. Alternatively > assuming you have enough of the source you could recreate the code that > builds > the constants via macros from C code. > > > If the constants vary from platform to platform but not run-to-run you can > use an approach like AdaSockets does > where it builds the ada spec on the fly during the configure step using > constants.sh and constants.c > (see the Adasockets distribution) > http://www.rfc1149.net/devel/adasockets > > tx. I just realized that with gnat I can import the constants directly. I realized that the ada specifications in the RM do never explicitly mention functions or procedures with respect to pragma import. So I did: H5T_STD_I32BE_g : Hid_t; pragma Import(C,H5T_STD_I32BE_g , "H5T_STD_I32BE_g"); and it works! All you have to do is call H5open manually, which is done automatically with the c preprocessor. Is this behaviour compiler-dependant, or ADA standard? I'm surprised, because there was this long thread on this very topic explicitly stating that ada cannot import c constants... But I guess it only referred to preprocessor constants. All "variing" constants are of course real c constants visible in the library. Thanx a lot for the reply. Chris