OO in C
As i tried to compile this portion of the Lomoco_Object.c code:
static void * Class_ctor (void * _self, va_list * app)
{
...
va_list ap = * app;
...
on my ppc i stumbled across a compiler error:
error:invalid initializer
which basically tells me *app is not of the type va_list, which struck me as odd on first sight. Some googling and fumbling arround with cc -E made me aware of the fact that the implementation of variable argument lists seem to be highly architecture dependent, and a more architecture portable way of achieving a copy of an argument list is calling the following GNU C extension (thereby trading compiler portability for arch. portability):
va_list ap;
#ifdef __va_copy
__va_copy( ap, *app );
#else
ap = * app;
#endif
All this made me curious enough to have a look at how all this variadic argument stuff is done in assembly by gcc, so i use cc -O0 -S and had a look at whats going on on that level. But i must admit that ppc assembly is quite different from ia32 *g* so i dug up this ibm article:
and this reference manual explaining ppc assembly:
PowerPC Microprocessor Family: The Programming Environments for 32-Bit Microprocessors
Previous Articles
Welcome to Sv3sch
Thank you for taking the time to visit my blog! Take a second to peek around and check out some of my previous posts. Of course, I would love to find out what you think as well, so make sure to comment. See you around!
