Wow, thanks for all the interesting replies. In the mean time here is what I came up with:
ld -r -b binary -o binary.o helloworld.txt #include <stdint.h> extern char _binary_helloworld_txt_start[]; extern char _binary_helloworld_txt_end[]; void* helloworld(uintptr_t* i) { uintptr_t a = (uintptr_t)&_binary_helloworld_txt_start; uintptr_t b = (uintptr_t)&_binary_helloworld_txt_end; (*i) = b - a; return &_binary_helloworld_txt_start; } gcc -c -o test.o test.c ar rcs libtest.a test.o binary.o program testresources; type TExternResource = function(out Size: UIntPtr): Pointer; function ResString(Res: TExternResource): string; var P: Pointer; I: UIntPtr; begin P := Res(I); SetLength(Result, I); Move(PChar(P)[0], PChar(Result)[0], I); end; function helloworld(out Size: UIntPtr): Pointer; cdecl; external; {$linklib test} var S: string; begin S := ResString(@helloworld); WriteLn(S); end.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal