Topic: Including binary data files


Author: galopin@gmail.com
Date: Wed, 2 Jan 2013 07:31:59 -0800 (PST)
Raw View
------=_Part_47_30648672.1357140719333
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

When i want to inline a binary file, i use a solution like objcopy, declare=
=20
the symbol in a header and let the linker do this work. This will probably=
=20
remains more efficient than letting a compiler loading a binary file at the=
=20
compilation stage.

Le lundi 8 octobre 2012 14:07:49 UTC+2, Olaf van der Spek a =E9crit :
>
> Sometimes, one wants to include binary data. Think of CRC or encryption=
=20
> tables, normal files (audio, images, whatever) or generated data.
> The traditional way is to either use a normal file and use ifstream or=20
> fopen etc, but this is a bit cumbersome. Or, one converts the binary data=
=20
> to C++ syntax and includes it the normal way.
>
> Wouldn't it be handier to be able to include a binary file natively into=
=20
> the executable and have it exposed as a byte (unsigned char) or other ran=
ge?
> Syntax and implementation can be very simple.
>

--=20




------=_Part_47_30648672.1357140719333
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

When i want to inline a binary file, i use a solution like objcopy, declare=
 the symbol in a header and let the linker do this work. This will probably=
 remains more efficient than letting a compiler loading a binary file at th=
e compilation stage.<br><br>Le lundi 8 octobre 2012 14:07:49 UTC+2, Olaf va=
n der Spek a =E9crit&nbsp;:<blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Som=
etimes, one wants to include binary data. Think of CRC or encryption tables=
, normal files (audio, images, whatever) or generated data.<div>The traditi=
onal way is to either use a normal file and use ifstream or fopen etc, but =
this is a bit cumbersome. Or, one converts the binary data to C++ syntax an=
d includes it the normal way.</div><div><br></div><div>Wouldn't it be handi=
er to be able to include a binary file natively into the executable and hav=
e it exposed as a byte (unsigned char) or other range?</div><div>Syntax and=
 implementation can be very simple.</div></blockquote>

<p></p>

-- <br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_47_30648672.1357140719333--

.


Author: Olaf van der Spek <olafvdspek@gmail.com>
Date: Wed, 2 Jan 2013 09:25:48 -0800 (PST)
Raw View
------=_Part_380_16545694.1357147548536
Content-Type: text/plain; charset=ISO-8859-1

Op woensdag 2 januari 2013 16:31:59 UTC+1 schreef gal...@gmail.com het
volgende:

> When i want to inline a binary file, i use a solution like objcopy,
> declare the symbol in a header and let the linker do this work. This will
> probably remains more efficient than letting a compiler loading a binary
> file at the compilation stage.
>
>
Why do you think your solution would be more efficient?
How portable is your solution?

--




------=_Part_380_16545694.1357147548536
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Op woensdag 2 januari 2013 16:31:59 UTC+1 schreef gal...@gmail.com het volg=
ende:<br><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">When i want to inline=
 a binary file, i use a solution like objcopy, declare the symbol in a head=
er and let the linker do this work. This will probably remains more efficie=
nt than letting a compiler loading a binary file at the compilation stage.<=
br><br></blockquote><div><br></div><div>Why do you think your solution woul=
d be more efficient?&nbsp;</div><div>How portable is your solution?</div>

<p></p>

-- <br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_380_16545694.1357147548536--

.