From: Lucretia <laguest9000@googlemail.com>
Subject: Why can't I used a deferred constant in a case statement?
Date: Sat, 11 Jul 2015 08:19:37 -0700 (PDT)
Date: 2015-07-11T08:19:37-07:00 [thread overview]
Message-ID: <f5e52fb4-f3a4-4c81-8d20-57b3a0d4f581@googlegroups.com> (raw)
Hi,
In my SDL bindings, I made all my event constants deferred, but when I came to use them in a case statement, the compiler complained:
test.adb:61:24: choice given in case statement is not static
test.adb:64:24: choice given in case statement is not static
The code is:
declare
Event : SDL.Events.Events;
Finished : Boolean := False;
use type SDL.Events.Event_Types;
begin
loop
while SDL.Events.Poll (Event) loop
case Event.Common.Event_Type is
when SDL.Events.Quit => -- 61
Finished := True;
when SDL.Events.Key_Up => -- 64
SDL.Log.Put_Debug
("Key up event: " &
SDL.Events.Key_Codes'Image (Event.Keyboard.Key_Sym.Key_Code));
when others =>
null;
end case;
end loop;
exit when Finished;
end loop;
end;
Where Quit and Key_Up are deferred:
package SDL.Events is
type Event_Types is mod 2 ** 32 with
Convention => C;
Quit : constant Event_Types;
Key_Up : constant Event_Types;
private
Quit : constant Event_Types := 16#0000_0100#;
Key_Up : constant Event_Types := Key_Down + 1;
end SDL.Events;
I can't find anything about this anywhere.
Luke.
next reply other threads:[~2015-07-11 15:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-11 15:19 Lucretia [this message]
2015-07-13 19:16 ` Why can't I used a deferred constant in a case statement? Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox