"Martin Dowie" a �crit dans le message news: 3bf3d68c$1@pull.gecm.com... > "Wilhelm Spickermann" wrote in message > news:mailman.1005833842.603.comp.lang.ada@ada.eu.org... > Hi, > > I would like to get a compilation *error*, if some compile time > constant is not suitable for the algorithm in use. Example: > > Chunk_Bits : constant := > Integer'Min (32, System.Max_Binary_Modulus / 2); > type Check is (Checkitem1, Checkitem2); > for Check'SIZE use 1 - Integer'MIN (96 mod Chunk_Bits, 1); > > The last two lines result in a compilation error, if and (I > hope) only if 96 is not a multiple of Chunk_Bits. That�s what I > want -- but it�s really ugly. Does anyone have something better? > > > Could try: > > type A_Valid_Range is range 0 .. 0; > > My_Check : constant A_Valid_Range := > A_Valid_Range (96 mod (Integer'Min (32, System.Max_Binary_Modulus / > 2))); > > This will probably raise a warning rather than an error though. > Some compilers will let you specify that warning are to be > treated as errors. To get an error, do the following: subtype Assert is boolean range True..True; Check : constant := Assert'Pos(96 rem Chunk_Bits = 0) Since Check is a named number, an invalid value will result in a compile time error (new in 95). -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr