C locale

Jacob Carlborg doob at me.com
Sat Sep 28 10:34:23 PDT 2013


On 2013-09-28 02:28, "Luís Marques" <luis at luismarques.eu>" wrote:
> BTW, I have for more than once wondered why there was no way to specify
> more than one version identifier (is there?), like this:
>
>      version(Windows, OSX)
>      {
>          enum LC_ALL            = 0;
>          enum LC_COLLATE        = 1;
>          enum LC_CTYPE          = 2;
>          enum LC_MONETARY       = 3;
>          enum LC_NUMERIC        = 4;
>          enum LC_TIME           = 5;
>      }
>      version(OSX)
>      {
>
>          enum LC_MESSAGES       = 6;
>      }
>
> Is there a way to use version() that avoids having to repeat the equal
> declarations for both Windows and OSX?

If you really want to do this, despite what Walter has said. You can use 
manifest constants and static ifs:

version (OSX)
     enum OSX = true;
else
     enum OSX = false;

version (linux)
     enum linux = true;
else
     enum linux = false;

And so on

static if (linux || OSX)
{
}
else {}

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list