Re: accessing record element (question to the pros)



"Jeffrey R. Carter" <spam@xxxxxxxx> writes:

However, in general, you can't do what you seem to be trying to
do. Variant records do not allow unchecked type conversion; the
language rules prohibit it. That's what Ada.Unchecked_Conversion is
for.

GNAT (certainly in recent versions) has pragma Unchecked_Union
(http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gnat_rm/Pragma-Unchecked_005fUnion.html#Pragma-Unchecked_005fUnion).

NB, compiler-specific.
.



Relevant Pages

  • Re: problem with ada.interrupts
    ... AdaMagic compilers, on WindowsXP, Linux, and Solaris. ... trigger an entry barrier, and have some task wait for the entry. ... You need a pragma on the SIGINT_Handler. ... On GNAT, you need pragma Unreserve_All_Interrupts on some systems. ...
    (comp.lang.ada)
  • Re: Reliability and deadlock in Annex E/distributed code
    ... Under gnat 3.15p for x86 Linux, things were tolerably OK, with failures ... there was some boot server failure. ... package body A is ... pragma Remote_Call_Interface; ...
    (comp.lang.ada)
  • Re: DLLs with GNAT?
    ... >> I try to write a DLL with GNAT but I've got some problem. ... package API is ... pragma Export; ...
    (comp.lang.ada)
  • Re: accessing record element (question to the pros)
    ... Variant records do not allow unchecked type conversion; the language rules prohibit it. ... For the specific problem of accessing bits in an unsigned integer, you can use the logical operators on modular types: and, or, Shift_Right, and so on. ... For a signed integer, you can unchecked convert to an array of Boolean, but then you have a portability problem: is the LSB in 'First or 'Last? ...
    (comp.lang.ada)
  • Re: [No_Elaboration_Code] GNAT still generating rep_to_pos, why?
    ... > gnat rm for similar pragmas; I think there is one to suppress the enum ... pragma Restrictions; ... This is in the GNAT RM from the GCC site: ... > Well, GNAT is not normally used to build kernels, and kernels are ...
    (comp.lang.ada)