A couple of GCC versions ago, I could do neat things like this:
$ objcopy -I binary -O elf64-x86-64 -B i386 foo.png foo.png.o
... coupled by the following in C, as an example with SDL image loading:
extern void _binary_foo_png_start;
extern void _binary_foo_png_start;
SDL_Surface *image = IMG_Load_RW(SDL_RWFromMem(&_binary_foo_png_start, &_binary_foo_png_end));
Then I would link foo.png.o
together with the object file from the C file and get an executable which neatly contained foo.png
.
These days, I can still do that, but GCC warns me about it:
foo.c:57:19: warning: taking address of expression of type ‘void’
foo.c:57:44: warning: taking address of expression of type ‘void’
Clearly it still works, and as far as I can tell, it really does what it's supposed to. The symbols themselves have no well defined type, and therefore it seems fitting to declare them as void
. I mean, sure, I could just as well give them any other arbitrary type and it would still work just as well seeing as how I just want their address anyway, but declaring them void
seemed nicer than just making up some type.
So why has GCC suddenly decided to start warning me about this? Is there some other preferred way that this should be done?