From: Keith Thompson <kst@cts.com>
Subject: Re: Help interfacing C
Date: 2000/07/25
Date: 2000-07-25T00:00:00+00:00 [thread overview]
Message-ID: <yecitttzebi.fsf@king.cts.com> (raw)
In-Reply-To: 8ljlti$7u0$1@polaris.inta.es
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1544 bytes --]
"Jes�s M. Mil�n-Franco" <milanjm@inta.es> writes:
> I have to do an Ada interface to a C library and I have found the
> following function declaration:
>
> int zzz_VaSend (zzz_mbox_cap mbox_c, int send_type,
> int flag, int len, char *buf , char *va_list, ...);
>
> Where va_list is a list with the receiver names finished by 'null', so
> the function has a variable number of parameters (the last is always
> null)
>
> Does anybody know if it is possible to have something similar in Ada ??
Not directly, at least not portably.
A C function whose declaration includes a "..." token takes a variable
number of arguments; the body of the function uses the facilities
defined in the standard header <stdarg.h> to retrieve them. Ada has
no such facility. (Overloading and default parameters can provide
much of the same functionality, but that doesn't help much when you're
trying to interface directly to a C function like this one.)
You can define a list data structure that you can construct on the Ada
side and pass to an intermediate C function, but even in C building a
variable argument list from a list or array of values is tricky or
even impossible. It's done with compiler magic.
Your best bet is to find or create a function or set of functions that
does what zzz_VaSend does, but without using "...".
--
Keith Thompson (The_Other_Keith) kst@cts.com <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Welcome to the last year of the 20th century.
next prev parent reply other threads:[~2000-07-25 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-07-25 0:00 Help interfacing C Jes�s M. Mil�n-Franco
2000-07-25 0:00 ` Keith Thompson [this message]
2000-07-26 0:00 ` Ken Garlington
2000-07-26 0:00 ` tmoran
2000-07-26 0:00 ` Keith Thompson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox