July 07, 2007 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 |
July 07, 2007 Re: Initializing a static array/struct from a binary file | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dan | 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.'). |
Copyright © 1999-2021 by the D Language Foundation