This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Java compiler patch: compile resource files into executables
Zack wrote:
> Let me give a simple example of the sort of code one would like to be
> able to write.
Here's an example of using `gcj -R' with a C program. However, now that I've
given it some thought, I don't think we should document the format in user
documentation. _Jv_RegisterResouce is part of the gcj ABI, and promoting it's
use elsewhere just seems wrong. It certainly makes it tricky to link together
gcj code and C code using this hack.
AG
$ cat foo.c
#include <stdio.h>
void _Jv_RegisterResource (void *vptr)
{
const char *nptr = (const char *)(vptr + 2 * sizeof(unsigned));
int nlength = ((int *)vptr)[0];
int dlength = ((int *)vptr)[1];
{
char buf[nlength + 1];
strncpy (buf, nptr, nlength);
buf[nlength] = 0;
printf ("%s\t%d bytes\n", buf, dlength);
}
}
int
main (int argc, char *argv[])
{
puts ("done.");
}
$ gcj -R poppy -o poppy.o -c foo.c -fno-exceptions
$ gcc -o foo foo.c poppy.o
$ ./foo
/poppy 390 bytes
done.
$ ls -l foo.c
-rw-rw-r-- 1 green cygnus 390 Sep 3 14:05 foo.c