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!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Thu, 26 Aug 2004 14:19:21 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: Subject: Re: trying to call HDF5 from ada -- problems with constants Date: Thu, 26 Aug 2004 14:20:16 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-9aOMnajks0TChmaTAbcf5m0PFmCMKS3lkYKqFxMvDJfriRPRG3f2EVecTLbOztXBHmJPbak/AJ4KyVD!Gk6bL5ZAjjNiECNQ4rQav1Jsrx2hGTJ8njG8j2+2T1g8CgCG69zALrky0+jNWAyOak7KSX4fyJOR X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.13 Xref: g2news1.google.com comp.lang.ada:3044 Date: 2004-08-26T14:20:16-05:00 List-Id: "Christopher Broeg" wrote in message news:cgkii4$lga$1@fsuj29.rz.uni-jena.de... ... > 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? Pragma Import on objects is standard (presuming interface to C is supported by the implementation). Since this object is going to be a constant in the Ada code, it's unfortunate that you can't declare it that way: H5T_STD_I32BE_g : constant Hid_t; but that lack of an explicit initializer makes it illegal. (I think an implementation could support this if it wanted to - pragma Import can be a completion - but I don't know if any do.) > 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. I certainly thought you were talking about preprocessor constants. I've never seen a library level constant in C, so I never thought that you might be talking about that. I suspect that is true of most of the people here. Randy.