Initializing a static array/struct from a binary file

torhu fake at address.dude
Sat Jul 7 10:21:33 PDT 2007


Dan wrote:
> A feature that would be quite convienient is the ability to initialize a
> static array or struct from a binary file. Good for things like lookup
> tables and graphics data. Portability is no problem; just document the
> binary format as being x86 style (e.g. little endian), no matter what the
> hardware.

Have you tried using an import expression?  I think it does exactly what 
you're asking for.

ubyte[] data = cast(ubyte[])import("stuff.dat");

compile with the -J parameter ('-J.').



More information about the Digitalmars-d mailing list