Binary data in the code?

BCS empty at pathlink.com
Sat Nov 4 11:02:31 PST 2006


== Quote from Bill Baxter (wbaxter at gmail.com)'s article
> How does one embed binary data in code with D?
> In C/C++ one would do something like:
>    static const unsigned char data[] = {99,12,2,21};
> The compiler counts the elements for you, but you still get a
> compile-time length, so you can do sizeof(data) and you'll get
> back 4 in the above example.
[...]
> Thanks,
> --bb


IIRC, this works:

auto data = [cast(char)99,12,2,21];
// type of data == char[4];



More information about the Digitalmars-d-learn mailing list