Does anyone try to use __attribute__((packed)) for enum?
Gcc 4.0.0 has -fshort-enums command option and also accepts __attribute__((packed)) http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Type-Attributes.html Sun Studio 12 Update 1 supports _attribute_((packed)) http://developers.sun.com/sunstudio/support/CCcompare.html A value of "enum" is normally treated as "int." Thus, the size of enum variable might be 4 bytes. The number of items declared is, however, usually less than 255. It can be stored in a single byte rather than 4 bytes. For example, http://hg.services.openoffice.org/OOO330/file/OOO330_m20/vcl/inc/vcl/impfont.hxx In the file above, sizeof( Impl_Font ) reaches at 88 bytes on Solaris x86. The class Impl_Font includes 11 member variables of enum. Each enum variable occupies 4 bytes. The total size of the class instance could be reduced to around 50 bytes, or -43%, if "packed" enum is applied and byte alignment between adjacent members -- i.e. the order of member variables -- is carefully taken into account. Such a modifier might be defined depending on what compiler and its version is used: http://hg.services.openoffice.org/OOO330/file/OOO330_m20/sal/inc/sal/types.h I believe packing an "enum" value from 4 bytes to 1 byte greatly benefits while packing "struct" generally produces inefficient, assembler-level, additional instructions. Any thoughts? Tora -- ----------------------------------------------------------------- To unsubscribe send email to dev-unsubscr...@openoffice.org For additional commands send email to sy...@openoffice.org with Subject: help