Yields "foo.adb:12:04: warning: types for unchecked conversion have different sizes"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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