News for hackers. Stuff that matters.
Re:Embedding files in C programs with koio by kccqzy on Wednesday May 30, 2018 @04:37PM (#17191536)
Even xxd has a mode to dump a file in the way expected by C. From then it's just another #include away.
Re:Embedding files in C programs with koio by makapuf on Wednesday May 30, 2018 @04:53PM (#17191678)
I personnally end up using my own simple python scripts.

Alternatives being : - use objcopy but this needs to specify the binary of the output, which some build settings can make complex at the compile stage - use ld and -o binary. this works but this will put all data in .data section which puts it in ram, without being able to change it. - use incbin on inline assembly. this will work too but it's slightly more complex and relies on inline assembly so a bit less portable. - use xxd utility : this only works on linux, does not export const unsigned char[] (fixable with a simple sed) and we lack the ability to export just a header or control prefix / extensions.