This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
call through pointer of function with variable arguments
- From: Stephen Biggs <xyzzy at hotpop dot com>
- To: GCC list <gcc at gcc dot gnu dot org>
- Date: 04 Jun 2003 19:19:00 +0300
- Subject: call through pointer of function with variable arguments
Given this code:
#include <stdio.h>
char buf[2];
int (*gfp)(char *, const char *, ...);
int (*gfp1)(const char *, ...);
void f (fp,fp1)
int (*fp)(char *, const char *, ...);
int (*fp1)(const char *, ...);
{
(*fp1)("%.0f\n",5.0);
(*fp)(buf, "%.0f", 5.0);
}
void h(void)
{
gfp = sprintf;
gfp1 = printf;
(*gfp1)("%.0f\n",5.0);
(*gfp)(buf, "%.0f", 5.0);
}
int main()
{
f (&sprintf,&printf);
h ();
return 0;
}
... in both the cases, by the time I get to the point where I receive an
expression for the call (in either f or g), the function pointer value
has already been moved to a register and no prototype information is
available, since all I have is the function address (in my port, the
arguments for the current call are already saved aside). The
proprietary machine I am porting to is sensitive to whether a call has
variable arguments or not and has a different calling sequence based on
that, but how can I know?
Are there any other machines that already have been ported that have
this sensitivity?