Correct way to map C #define to version

Sumit Raja sumitraja at gmail.com
Mon Oct 29 06:47:46 PDT 2012


On Monday, 29 October 2012 at 12:31:56 UTC, Regan Heath wrote:
> On Mon, 29 Oct 2012 11:31:33 -0000, Sumit Raja 
> <sumitraja at gmail.com> wrote:
>> Thanks both this works great for structs. Anything similar I 
>> can do for enums?
>
> Example?  (The C/C++ code you're trying to convert..)

Yeah that might help... One example here (though it seems 
slightly inconsistent as the enum following the second if seems 
to be padded for the values inside the ifdef):

enum PixelFormat {
     PIX_FMT_NONE= -1,
.
.
.
#ifdef AV_PIX_FMT_ABI_GIT_MASTER
     PIX_FMT_RGBA64BE,  ///< packed RGBA 16:16:16:16, 64bpp, 16R, 
16G, 16B, 16A, the 2-byte value for each R/G/B/A component is 
stored as big-endian
     PIX_FMT_RGBA64LE,  ///< packed RGBA 16:16:16:16, 64bpp, 16R, 
16G, 16B, 16A, the 2-byte value for each R/G/B/A component is 
stored as little-endian
     PIX_FMT_BGRA64BE,  ///< packed RGBA 16:16:16:16, 64bpp, 16B, 
16G, 16R, 16A, the 2-byte value for each R/G/B/A component is 
stored as big-endian
     PIX_FMT_BGRA64LE,  ///< packed RGBA 16:16:16:16, 64bpp, 16B, 
16G, 16R, 16A, the 2-byte value for each R/G/B/A component is 
stored as little-endian
#endif
     PIX_FMT_GBRP,      ///< planar GBR 4:4:4 24bpp
.
.
.
     PIX_FMT_GBRP16LE,  ///< planar GBR 4:4:4 48bpp, little endian

#ifndef AV_PIX_FMT_ABI_GIT_MASTER
     PIX_FMT_RGBA64BE=0x123,  ///< packed RGBA 16:16:16:16, 64bpp, 
16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component 
is stored as big-endian
     PIX_FMT_RGBA64LE,  ///< packed RGBA 16:16:16:16, 64bpp, 16R, 
16G, 16B, 16A, the 2-byte value for each R/G/B/A component is 
stored as little-endian
     PIX_FMT_BGRA64BE,  ///< packed RGBA 16:16:16:16, 64bpp, 16B, 
16G, 16R, 16A, the 2-byte value for each R/G/B/A component is 
stored as big-endian
     PIX_FMT_BGRA64LE,  ///< packed RGBA 16:16:16:16, 64bpp, 16B, 
16G, 16R, 16A, the 2-byte value for each R/G/B/A component is 
stored as little-endian
#endif
     PIX_FMT_0RGB=0x123+4,      ///< packed RGB 8:8:8, 32bpp, 
0RGB0RGB...
.
.
.
};



More information about the Digitalmars-d-learn mailing list