www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15601] New: version not allowed within enum declaration

https://issues.dlang.org/show_bug.cgi?id=15601

          Issue ID: 15601
           Summary: version not allowed within enum declaration
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: epi atari8.info

The following declaration is not accepted. Compiler complains "Error: basic
type expected, not version".
It can be worked around by versioning the entire enum declaration (code
duplication) or string mixin (ugly).

enum snd_pcm_format_t
{
    UNKNOWN = -1,
    S8 = 0,
    U8,
    S16_LE,
    S16_BE,
    U16_LE,
    U16_BE,
    S24_LE,
    S24_BE,
    U24_LE,
    U24_BE,
    S32_LE,
    S32_BE,
    U32_LE,
    U32_BE,
    FLOAT_LE,
    FLOAT_BE,
    FLOAT64_LE,
    FLOAT64_BE,
    IEC958_SUBFRAME_LE,
    IEC958_SUBFRAME_BE,
    MU_LAW,
    A_LAW,
    IMA_ADPCM,
    MPEG,
    GSM,
    SPECIAL = 31,
    S24_3LE = 32,
    S24_3BE,
    U24_3LE,
    U24_3BE,
    S20_3LE,
    S20_3BE,
    U20_3LE,
    U20_3BE,
    S18_3LE,
    S18_3BE,
    U18_3LE,
    U18_3BE,
    G723_24,
    G723_24_1B,
    G723_40,
    G723_40_1B,
    DSD_U8,
    DSD_U16_LE,
    LAST = DSD_U16_LE,

    version(LittleEndian)
    {
        S16 = S16_LE,
        U16 = U16_LE,
        S24 = S24_LE,
        U24 = U24_LE,
        S32 = S32_LE,
        U32 = U32_LE,
        FLOAT = FLOAT_LE,
        FLOAT64 = FLOAT64_LE,
        IEC958_SUBFRAME = IEC958_SUBFRAME_LE
    }
    else version(BigEndian)
    {
        S16 = S16_BE,
        U16 = U16_BE,
        S24 = S24_BE,
        U24 = U24_BE,
        S32 = S32_BE,
        U32 = U32_BE,
        FLOAT = FLOAT_BE,
        FLOAT64 = FLOAT64_BE,
        IEC958_SUBFRAME = IEC958_SUBFRAME_BE
    }
    else
    {
        static assert(0, "Unknown endian");
    }
}

--
Jan 24