[fpc-pascal] Placing binary data (resources) in object files?

Rainer Stratmann rainerstratmann at t-online.de
Mon Jun 3 18:40:54 CEST 2013


 On Monday 03 June 2013 17:47:46 you wrote:
> I am trying to come up with an embedded binary resource system and was
> considering placing data in object files when I found this question on
> stack overflow:
> http://stackoverflow.com/questions/4158900/embedding-resources-in-exe-using
> -gcc
> 
> I see that it's possible to directly turn any file into an object file and
> reference the memory of that as a resource in a C program using:
> 
> extern char binary_foo_bar_start[];
> extern char binary_foo_bar_end[];
> 
> My question, is it possible to link extern char in free pascal in a way
> similar to above? Perhaps something similar to:
> 
> var binary_foo_bar_start: pointer; external;
> 
> {$L foo.bar.o}
> 
> Or some permutation of the above? 

For example: (see mentioned topic)

// get access to the data of file.dat
// have 1 executable file with containing all the data

{$ir file.dat mydata} // include resource or similar

// fpc compiler makes this
const
 mydata : array[ 0 .. 4 ] of byte =
 ($45,$44,$63,$76,$55); // file data

// the length can find out with sizeof( mydata );



More information about the fpc-pascal mailing list