comp.lang.ada
 help / color / mirror / Atom feed
* Why can't I used a deferred constant in a case statement?
@ 2015-07-11 15:19 Lucretia
  2015-07-13 19:16 ` Randy Brukardt
  0 siblings, 1 reply; 2+ messages in thread
From: Lucretia @ 2015-07-11 15:19 UTC (permalink / 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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-13 19:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-11 15:19 Why can't I used a deferred constant in a case statement? Lucretia
2015-07-13 19:16 ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox