Live data from Hacker News

C/C++ Embedded Files (2013)

4rknova.com

11–20 of 57 posts

Re: C/C++ Embedded Files (2013)

#11
post #3

surely the preprocessor method doesn't work in the general case, since the data can contain commas or parentheses. Regardless all of the methods suggested are terrible. If you don't have access to #embed, just write a trivial python script.

How is `xxd -i' terrible?

Re: C/C++ Embedded Files (2013)

#13
post #3

surely the preprocessor method doesn't work in the general case, since the data can contain commas or parentheses. Regardless all of the methods suggested are terrible. If you don't have access to #embed, just write a trivial python script.

How is `xxd -i' terrible?

It's still lacking content that goes before/after the output.

Just write a Python script that does the whole thing.

Re: C/C++ Embedded Files (2013)

#14

Earlier quoted context omitted.

How is `xxd -i' terrible?

It's still lacking content that goes before/after the output. Just write a Python script that does the whole thing.

Don't know what you mean, it works fine here. Python is too large and unreliable a dependency for something so trivial (which can be accomplished using standard POSIX utilities if need be).

Re: C/C++ Embedded Files (2013)

#15
post #3

surely the preprocessor method doesn't work in the general case, since the data can contain commas or parentheses. Regardless all of the methods suggested are terrible. If you don't have access to #embed, just write a trivial python script.

You can apply `#` to __VA_ARGS__, which won’t preserve the exact whitespace, but for many languages it’s good enough. biggest issue is you can’t have `#` in the text.

Re: C/C++ Embedded Files (2013)

#16
post #2

Outdated, modern solution is baked in now https://en.cppreference.com/w/c/preprocessor/embed

The thing that always irks me about c++ is this sort of thing: > Explanation 1) Searches for the resource identified by h-char-sequence in implementation-defined manner. Okay, so now I have to make assumptions that the implementation is reasonable, and won't go and "search" by asking an LLM or accidentally revealing my credit card details to a third party, right? And even if the implementation _is_ reasonable the onl…

If you want to remain portable, write your code in the intersection of the big 3 - GCC, Clang and MSVC - and you’ll be good enough. Other implementations will either be weird enough that many things you’d expect to work won’t or are forced to copy what those 3 do anyway.

Re: C/C++ Embedded Files (2013)

#17
My current workaround until it arrives in all C++ compilers

``` inline constexpr auto bootstrap = #include "bootstrap.lua" ;

// ... later

lua.script(bootstrap, "@bootstrap"); ```

The lua code ``` R"( -- your code here )"; ```

Re: C/C++ Embedded Files (2013)

#18

You can also do it using ld - it's something like ld -r --format binary -o out.o , although you do want some build system assistance to generate header files allowing you to access the thing (somewhat similar to the assembly example here). It's a bit of a performance but I strongly prefer it to generating header files in the earlier options - those header files can end up being _very_ large (they generally multiply u…

The special ld argument is a gnu thing, it's not portable and at least lld doesn't support it.

https://github.com/jcalvinowens/ircam-viewer/commit/17b3533b...

Re: C/C++ Embedded Files (2013)

#19
post #2

Outdated, modern solution is baked in now https://en.cppreference.com/w/c/preprocessor/embed

let me know when my embedded target's compiler is C23 compliant (i mean, i whish. we may be getting C11 or even C17 some times next year but i'm not holding my breath)
Post reply on HN