Conversation
Notices
-
Embed this notice
@rozenglass #embed is not only portable, but also not tied to vim (yes, the vim package ships xxd, don't ask me why they didn't make it a separate tool), and if you're embedding anything remotely big (like say, model or texture data like it's helpful to do with graphics programming), then a properly implemented embed will speed up your compile times a *ton*
- Haelwenn /элвэн/ :triskell: likes this.
-
Embed this notice
In other news, why did no one tell me about xxd -i before:
-i | -include
Output in C include file style. A complete static array defini‐
tion is written (named after the input file), unless xxd reads
from stdin.
For example, you can add this to your build pipeline, to turn a string to an embedded array of characters. Just #include printf-template.html.h in your code. If printf-template.html contains printf control sequences, like %s, they do work if you pass them to printf(). You can have an HTML file parametrized with printf() for example.
xxd -i printf-template.html > printf-template.html.h
I assume you can embed anything this way; strings, images, 3D models, etc. This seems cross-platform enough. I'm starting to wonder if the new #embed C standard proposal is really needed, or just bloat now. (Even parameterized #embed sounds like something replaceable with some UNIX piping before you pass the data to xxd -i).