From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,INVALID_MSGID, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,40e33eaeae684c37 X-Google-Attributes: gid103376,public From: Keith Thompson Subject: Re: Help interfacing C Date: 2000/07/25 Message-ID: #1/1 X-Deja-AN: 650838930 Sender: kst@king.cts.com References: <8ljlti$7u0$1@polaris.inta.es> X-Trace: thoth.cts.com 964586945 67502 205.163.0.22 (26 Jul 2000 04:49:05 GMT) Organization: CTSnet Internet Services Newsgroups: comp.lang.ada X-Complaints-To: abuse@cts.com Date: 2000-07-25T00:00:00+00:00 List-Id: "Jes�s M. Mil�n-Franco" 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 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 San Diego Supercomputer Center <*> Welcome to the last year of the 20th century.