Size attribute

mail@pastecode.io avatar
unknown
ada
8 months ago
673 B
7
Indexable
Never
procedure Size_Test is

   subtype String_5_Type is String (1 .. 5);

   type RecA is record
      Field : String_5_Type := (others => ' ');
   end record;

   type RecB is record
      Field : String_5_Type := (others => ' ');
   end record;

   A : RecA;
   B : RecB;

begin
   pragma Compile_Time_Error (A.Field'Size /= B.Field'Size, "Ehh?!");
   pragma Compile_Time_Error (A.Field'Size /= A.Field'Size, "Ehhhhh ?!???");
   null;
end Size_Test;

----

gnatmake size_test
gcc -c size_test.adb
size_test.adb:17:44: error: condition is not known at compile time
size_test.adb:18:44: error: condition is not known at compile time
gnatmake: "size_test.adb" compilation error
Leave a Comment