HP OpenVMS Systems

ask the wizard
Content starts here

64bit stdarg.h variable arguments?

» close window

The Question is:

Is there a decent implementation/support of varargs.h (stdarg.h) for 64bit
 applications? According to the definitions in both headers there is only
 _ptr32 support.

The Answer is :

  Do not be confused by the cast to __char_ptr32 seen within the va_start
  and va_arg macros.  As you can observe from the attached example, the
  macros allow retrieving (long long) quadword values.
$ pipe cc x ; link x ; run x
$ pipe cc/poin=long x ; link x ; run x
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
void foo(int i, ...) {
    va_list ap;
    void *ptr;
    va_start(ap, i);
    ptr = va_arg(ap, void*);
    printf("%llx\n", ptr);
main () {
   void *ptr = malloc(1);
   foo(0, ptr);

answer written or last revised on ( 14-JUL-2004 )

» close window