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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,40e33eaeae684c37 X-Google-Attributes: gid103376,public From: Keith Thompson Subject: Re: Help interfacing C Date: 2000/07/26 Message-ID: #1/1 X-Deja-AN: 651111827 Sender: kst@king.cts.com References: <8ljlti$7u0$1@polaris.inta.es> X-Trace: thoth.cts.com 964641499 13517 205.163.0.22 (26 Jul 2000 19:58:19 GMT) Organization: CTSnet Internet Services Newsgroups: comp.lang.ada X-Complaints-To: abuse@cts.com Date: 2000-07-26T00:00:00+00:00 List-Id: tmoran@bix.com writes: > > int zzz_VaSend (zzz_mbox_cap mbox_c, int send_type, > > int flag, int len, char *buf , char *va_list, ...); > > You could use overloading > function f(some_params:some_type; a:another_type); > function f(some_params:some_type; a,b:another_type); > function f(some_params:some_type; a,b,c:another_type); > That works well if you usually only have a few items in the variable > parameter list. If the overloaded function f is interfaced directly to zzz_VaSend(), this will work only if the C implementation passes ordinary arguments and variable (stdarg) arguments the same way. This is probably true of many, but not all, implementations. On the other hand, assuming a C function like this: int f(some_type arg1, ...); you could do something like this: function F1(Arg1: Some_Type) return Interfaces.C.int; pragma Import(C, F1); function F2(Arg1: Some_Type; Arg2: Another_Type) return Interfaces.C.int; pragma Import(C, F2); function F3(Arg1: Some_Type; Arg2, Arg3: Another_Type) return Interfaces.C.int; pragma Import(C, F3); -- Use renaming declarations to overload F1, F2, F3 as F and in C: int f1(some_type arg1) { return f(arg1); } int f2(some_type arg1, another_type arg2) { return f(arg1, arg2); } int f3(some_type arg1, another_type arg2, another_type arg3) { return f(arg1, arg2, arg3); } -- Keith Thompson (The_Other_Keith) kst@cts.com San Diego Supercomputer Center <*> Welcome to the last year of the 20th century.