digitalmars.D - Initializing a static array/struct from a binary file
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. Dan
Jul 07 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.').
Jul 07 2007