How to translate this C++ preprocessor declaration in D?

Heinz thor587 at gmail.com
Fri May 24 19:55:17 PDT 2013


Guys, i also did a templated version that yields the same output 
as the C++ program:

////////////////////////////////////////////////////////////////////////
import std.stdio;

template makeId(char[4] id)
{
	const makeId = id[0] << 24 | id[1] << 16 | id[2] << 8 | id[3];
}

const kPIHostBlendModeSignature = makeId!("8BIM");
const PIPowerPCCarbonCodeProperty = makeId!("ppcb");
const PIPowerPCMachOCodeProperty = makeId!("mach");
const PICodeMacIntel32Property = makeId!("mi32");
const PICodeMacIntel64Property = makeId!("mi64");

void main()
{
     writefln(kPIHostBlendModeSignature);
     writefln(PIPowerPCCarbonCodeProperty);
     writefln(PIPowerPCMachOCodeProperty);
     writefln(PICodeMacIntel32Property);
     writefln(PICodeMacIntel64Property);
}
////////////////////////////////////////////////////////////////////////

Thanks for your help.


More information about the Digitalmars-d-learn mailing list