import_binary Function (Macro Constructor)

default.h

#define import_binary(filename,symname) asm(".globl "#symname"\n"#symname":\n\t.incbin \""filename"\"")

Imports a binary file as an arbitrary symbol.

import_binary imports a binary file at the current position using the .incbin assembler directive. The parameter filename specifies the file name in quotes; symname specifies the symbol name to assign to the contents. You can give the symbol any type using an external definition; for example:

extern unsigned char myarray[];
import_binary ("myfile.bin", myarray);
It is not recommended to use import_binary at any place other than the top level, as binary contents placed inside functions will generally be interpreted as code.