comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: changing alignment of built-in boolean
Date: Sat, 15 Oct 2005 09:13:36 +0200
Date: 2005-10-15T09:13:36+02:00	[thread overview]
Message-ID: <6352843.iZBs4xBJdn@linux1.krischik.com> (raw)
In-Reply-To: 1129332814.670876.3310@g49g2000cwa.googlegroups.com

invalidemail@aerojockey.com wrote:

> Ludovic Brenta wrote:
>> invalidemail@aerojockey.com writes:
>>
>> > Is it possible, in GNAT, to force the built-in Boolean type to use
>> > 4-byte (32-bit) alignment?  Reason: I have to interface some Ada code
>> > to a package that insists on 32-bit variables on 4-byte-aligned
>> > addresses.

>> package P is
>>    subtype External_Boolean is Boolean;
>>    for External_Boolean'Size use 32;
>>    for External_Boolean'Alignment use 32;
> 
> Parenthetically, I tried this.  Compiler told me I cannot specify
> attribute for subtype.

A typo from Ludovic. you really need:

type External_Boolean is new Boolean;
for External_Boolean'Size use 32;
for External_Boolean'Alignment use 32;

Of corse you need an explicit convertion between Boolean and
External_Boolean. 

> Ok, I'm sorry.  I appear to have omitted a crucial piece of
> information: this is for library level Booleans.  The Ada code
> constitutes a shared library, and the program that calls the library
> accesses some of the library level variables via the symbol table, but
> the variables have to be 32-bits.

External_Boolean will work fine for that.

> The record way doesn't work either, at least not without extensive
> changes, because I still have to use these variables as Booleans (in
> conditional expressions).

> I was thinking that if there was a way to do this it would be to use
> some compiler flag or an obscure, implementation-defined pragma.
> 
> Thanks anyways. :)

Martin

-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



  reply	other threads:[~2005-10-15  7:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-14 20:03 changing alignment of built-in boolean invalidemail
2005-10-14 22:55 ` Ludovic Brenta
2005-10-14 23:33   ` invalidemail
2005-10-15  7:13     ` Martin Krischik [this message]
2005-10-17 18:02       ` Jean-Pierre Rosen
2005-10-14 23:29 ` tmoran
2005-10-15  1:39 ` Steve
2005-10-15  6:45   ` Jeffrey R. Carter
2005-10-15  6:40 ` Jeffrey R. Carter
2005-10-16 17:48   ` invalidemail
2005-11-09  3:25   ` Anonymous Coward
2005-11-09  5:42     ` christoph.grein
2005-11-09 22:14     ` Jeffrey R. Carter
replies disabled

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