I would say it is impossible. The calling sequence depends on the type of the arguments, and the declaration of the called function (ie, often times functions that use variable arguments have a different calling sequence than functions with a fixed number of arguments). For example, a 64 bit floating point value is often passed within a floating point register, but a 64 bit integer might be required to be passed in an even:odd register pair on a 32-bit system. One possible way of 'solving' the program is change the code to use variable argument function calling sequence, use va_start to create the va_list object and pass it to the child, much like is done with vprintf. -----Original Message----- From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On Behalf Of Jean-Sebastien Legare Sent: Thursday, July 21, 2005 6:51 PM To: gcc-help@xxxxxxxxxxx Subject: Constructing function calls Hi I have a special task I would like to accomplish regarding construction of function calls, without (preferably) using __asm__ sections. I would like to pass a block of data containing arguments to a function from which I don't know the type nor number of arguments. The only thing I know is the address of the function pointer and the size of the argument block (number of 32bit words). That is, I would like to fill this function: void call_func( (void*)func(), void* args, int size) { 1. push the contents of args to the stack; 2. call func() with no args (func will recuperate them from the stack); 3. return } For instance, I would like to be able to call : void print3ints(int a, int b, int c) { printf(" %d %d %d\n",a,b,c); } by doing : { int* args = malloc( 3 *sizeof(int)); args[0] = 1; args[1] = 2; args[2] = 3; call_func(print3ints,args,3); } I looked at "__builtin_apply" but it requires calling "__builtin_apply_args" beforehand, which I cannot do. I successfully managed to do that without using __asm__ on a x86. I filled a local int array in call_func with the passed argument block and then I called the passed function (stack bashing). However, the method breaks when compiling in -O3 mode and it would certainly not work on other systems where some arguments are passed inside registers. What are my best options ?