comp.lang.ada
 help / color / mirror / Atom feed
* 'Size hack for enumerated types
@ 2014-07-05 20:32 Victor Porton
  2014-07-05 21:47 ` Simon Wright
  2014-07-06 13:21 ` sbelmont700
  0 siblings, 2 replies; 26+ messages in thread
From: Victor Porton @ 2014-07-05 20:32 UTC (permalink / raw)


I have written the following code:

   type Flag_Type is (Libxml_Error_Save,
                      Libxml_Structured_Error_Save,
		      URI_Interning,
                      WWW_Skip_Init_Finish);
   for Flag_Type'Size use Interfaces.C.int'Size; -- hack
   for Flag_Type use (Libxml_Error_Save => 1,
                      Libxml_Structured_Error_Save => 2,
		      URI_Interning => 3,
                      WWW_Skip_Init_Finish => 4);

The code above is intended to be able to pass flag variables into certain C 
functions (accepting enum types).

But it seems that the above code has the drawback of storing in 4 or 8 bytes 
instead of one byte.

What is a better way to do this?

-- 
Victor Porton - http://portonvictor.org

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

end of thread, other threads:[~2014-07-08 23:18 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-05 20:32 'Size hack for enumerated types Victor Porton
2014-07-05 21:47 ` Simon Wright
2014-07-05 22:11   ` Victor Porton
2014-07-05 22:18     ` Victor Porton
2014-07-05 22:23       ` Victor Porton
2014-07-06 16:25         ` Victor Porton
2014-07-06 20:59       ` Simon Wright
2014-07-06 23:01         ` Victor Porton
2014-07-06 23:30           ` Jeffrey Carter
2014-07-07 16:00             ` Victor Porton
2014-07-07 17:12               ` Simon Wright
2014-07-07 20:23                 ` Victor Porton
2014-07-08  7:04                   ` Simon Wright
2014-07-08 10:17                     ` sbelmont700
2014-07-08 14:53                     ` Dan'l Miller
2014-07-08 20:56                       ` Randy Brukardt
2014-07-08 22:26                         ` Dan'l Miller
2014-07-08 23:18                         ` Jeffrey Carter
2014-07-08  9:43                   ` AdaMagica
2014-07-08 13:52                     ` Victor Porton
2014-07-08 15:02                       ` Simon Wright
2014-07-07  7:45           ` Simon Wright
2014-07-06  7:22     ` Simon Wright
2014-07-06 13:21 ` sbelmont700
2014-07-06 16:16   ` Victor Porton
2014-07-06 17:52     ` sbelmont700

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