Constant declarations for mac OSX

Oskar Linde oskar.lindeREM at OVEgmail.com
Thu Feb 23 08:25:53 PST 2006


Gareth Baker wrote:
> I'm running GDC on mac OSX. The mac tags events with a four character code which
> is converted to a 
> UInt32 along the lines of:
> 
> (s[0] << 24) || (s[1] << 16) || (s[2] << 8) || (s[3])
> 
> where s[n] is the ascii charater number.
> 
> I need to declare:
> 
> const OSType	kEventClassCommand            = FOUR_CHAR_CODE("cmds");


template FourCharCode(char[] s) {
   static assert(s.length == 4);
   const uint FourCharCode = (s[0]<<24)|(s[1]<<16)|(s[2]<<8)|(s[3]);
}

int main() {
   writefln("%x",FourCharCode!("cmds"));
   return 0;
}

/Oskar



More information about the Digitalmars-d-learn mailing list