Very naive question but I'm not sure to understand the benefit of embedding "big" resources at compile time (big as in it would not be practical to embed it in an array/string as described in the article).
Can someone give an example where it's strongly needed?
In every single case where you don't have a file system. In cases where you're building a frozen structure (for example perfect hashing based on compile-time data). Or when you are using building self-hosting self-contained programs. Custom operating systems.
There are executables on my hard drive (and probably yours) that are gigabytes in size (installers, self-extracting archives, etc) and the regular C/C++ toolchain should be able to painlessly create them, because their job is to produce binaries and leaving out such a simple "append bytes" feature is just making some people's lives harder for no reason.
I have a small program that edits epub books. I'd like to insert a particular image into the epubs as well. Right now i just distribute the exe and the jpg and tell users to pass arguments, but for the common case it'd sure be nice to just distribute a single file exe.
GTK programs bundle all sorts of stuff in their executables, like css themes, images, and xml ui definitions.
I don't know how strict you feel "strongly needed" is, but i hope these mundane circumstances are enough for you to accept a preprocessor directive that doesn't hurt anybody not using it.
It has been very common in the kind of applications that I've done (GUI-related, with Qt). Qt comes with a tool to do code generation on the files that you want as "resources" (the name it uses for the files that you embed). It is useful for icons, fonts, simple-settings, etc. I can help deployment, and make applications more self contained. The standard way it's gonna be much powerful, of course.
4
u/FightingGamesFan Jul 23 '22
Very naive question but I'm not sure to understand the benefit of embedding "big" resources at compile time (big as in it would not be practical to embed it in an array/string as described in the article).
Can someone give an example where it's strongly needed?