Skip to content

Instantly share code, notes, and snippets.

@flyx
Created January 28, 2012 16:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save flyx/1694959 to your computer and use it in GitHub Desktop.
Yields "foo.adb:12:04: warning: types for unchecked conversion have different sizes"
with Ada.Unchecked_Conversion;
with Interfaces.C;
with Ada.Text_IO;
procedure Foo is
type Bar is (Kol, Ra, Bi);
for Bar use (Kol => 1, Ra => 2, Bi => 3);
for Bar'Size use Interfaces.C.int'Size;
subtype Cocktail_Bar is Bar range Kol .. Ra;
function Convert is new Ada.Unchecked_Conversion (Source => Interfaces.C.int,
Target => Cocktail_Bar);
Value : Interfaces.C.int := 2;
begin
Ada.Text_IO.put (Convert (Value)'Img);
end Foo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment