D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15601 - version not allowed within enum declaration
Summary: version not allowed within enum declaration
Status: RESOLVED DUPLICATE of issue 9761
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-24 14:58 UTC by Adrian Matoga
Modified: 2020-03-21 03:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Adrian Matoga 2016-01-24 14:58:35 UTC
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");
	}
}
Comment 1 basile-z 2020-02-20 12:12:32 UTC

*** This issue has been marked as a duplicate of issue 9761 ***