comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: trying to call HDF5 from ada -- problems with constants
Date: Thu, 26 Aug 2004 14:20:16 -0500
Date: 2004-08-26T14:20:16-05:00	[thread overview]
Message-ID: <XrCdnb4o8vUnqrPcRVn-sg@megapath.net> (raw)
In-Reply-To: cgkii4$lga$1@fsuj29.rz.uni-jena.de

"Christopher Broeg" <broeg@astro.uni-jena.de~> 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.






  parent reply	other threads:[~2004-08-26 19:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-25 13:38 trying to call HDF5 from ada -- problems with constants Christopher Broeg
2004-08-25 16:35 ` Brian Catlin
2004-08-26  8:04   ` Christopher Broeg
2004-08-26 11:00     ` Jeff C,
2004-08-26 11:46       ` Christopher Broeg
2004-08-26 18:29         ` Ludovic Brenta
2004-08-26 19:20         ` Randy Brukardt [this message]
2004-08-27  0:54           ` Jeffrey Carter
2004-08-27 11:32             ` Christopher Broeg
replies disabled

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