Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>At its most basic, the equivalent is a <code>char</code> array full of bytes.</p> <p>On Linux you can use <code>xxd -i &lt;file&gt;</code> to "compile" files into <code>char</code> arrays, then link the arrays into your binary and use the constituent bytes however you please.</p> <p>Here's an example from my own code's <code>makefile</code>, that creates a "resource file" called <code>templates.h</code> containing a bunch of <code>char</code> arrays representing HTML templates:</p> <pre><code>templates.h: @echo "#ifndef REDACTED_TEMPLATES_H" &gt; templates.h @echo "#define REDACTED_TEMPLATES_H" &gt;&gt; templates.h @echo "// Auto-generated file! Do not modify!" &gt;&gt; templates.h @echo "// NB: arrays are not null-terminated" &gt;&gt; templates.h @echo "// (anonymous namespace used to force internal linkage)" &gt;&gt; templates.h @echo "namespace {" &gt;&gt; templates.h @echo "namespace templates {" &gt;&gt; templates.h @cd templates;\ for i in * ;\ do \ echo "Compiling $$i...";\ xxd -i $$i | sed -e 's/ =/ __attribute__((unused)) =/' &gt;&gt; ../templates.h;\ done;\ cd .. @echo "}" &gt;&gt; templates.h @echo "}" &gt;&gt; templates.h @echo "#endif" &gt;&gt; templates.h </code></pre> <p><sup>(<strong>see also:</strong> <a href="https://stackoverflow.com/q/7660494/560648">How best can I programmatically apply `__attribute__ ((unused))` to these auto-generated objects?</a>)</sup></p> <p>The result looks a little like:</p> <pre><code>#ifndef REDACTED_TEMPLATES_H #define REDACTED_TEMPLATES_H // Auto-generated file! Do not modify! // NB: arrays are not null-terminated // (anonymous namespace used to force internal linkage) namespace { namespace templates { unsigned char alert_email_finished_events_html[] __attribute__((unused)) = { 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6e, 0x6f, 0x64, 0x65, 0x2d, 0x69, 0x6e, 0x66, 0x6f, 0x2d, [..] 0x7d, 0x7d, 0x0d, 0x0a, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x0d, 0x0a }; unsigned int alert_email_finished_events_html_len __attribute__((unused)) = 290; unsigned char alert_email_finished_events_list_html[] __attribute__((unused)) = { 0x3c, 0x74, 0x72, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x2d, 0x70, 0x72, 0x65, 0x76, [..] 0x73, 0x74, 0x7d, 0x7d, 0x0d, 0x0a }; unsigned int alert_email_finished_events_list_html_len __attribute__((unused)) = 42; } } #endif </code></pre> <p>Note that this particular example is optimal when using the resource in only one Translation Unit, but the general approach can be adapted to suit your needs.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload