r/cpp • • Jul 23 '22

finally. #embed

https://thephd.dev/finally-embed-in-c23
353 Upvotes

202 comments sorted by

View all comments

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?

16

u/Mikumiku_Dance Jul 23 '22

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.

→ More replies (5)