This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with new stdarg implementation (gcc >= 2.9x)
- To: gcc at gcc dot gnu dot org
- Subject: Re: Problem with new stdarg implementation (gcc >= 2.9x)
- From: Bruno Haible <haible at ilog dot fr>
- Date: Fri, 22 Oct 1999 20:23:20 +0200 (MET DST)
- Cc: "Yuri A. Pudgorodsky" <yur dot ptci dot ru at ilog dot fr>
> What I ask for is an interface that allows pass a size instead of a tag
> and parse it this way:
>
> size = va_arg(ap, size);
> memcpy(datum, va_arg(ap, typeof(structofsize(size)), size);
It is impossible. Take for example mips in 64-bit mode. doubles inside
a structure are passed in floating point registers, not in integer registers.
If you only pass the size and alignment of the structure, the va_arg
macro will not be able to distinguish
struct { double x; }
and
struct { long x; }
and you will therefore get wrong results.
If you restrict yourself to structures which only contain `long' or `void*'
items, you can solve the problem by treating each CPU and ABI, one by one.
This approach has been realized in [1]. But beware: it is far from portable.
Bruno
[1] ftp://ftp.santafe.edu/pub/gnu/ffcall-1.6.tar.gz