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,c6e016ae58737f34 X-Google-Attributes: gid103376,public From: David Botton Subject: Re: win32ada design question/problem Date: 1998/11/19 Message-ID: <365455D5.9A1D0B23@Botton.com>#1/1 X-Deja-AN: 413567276 Content-Transfer-Encoding: 7bit References: <364C5EDE.4F402D13@elca-matrix.ch> <364c90eb.10939677@SantaClara01.news.InterNex.Net> <36501A46.82C348D3@elca-matrix.ch> <36531538.483857@SantaClara01.news.InterNex.Net> <365454A8.EFCA84F9@elca-matrix.ch> Content-Type: text/plain; charset=us-ascii Organization: IQuest Internet, Inc. Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-11-19T00:00:00+00:00 List-Id: Mats Weber wrote: > On the other hand, > > type String_Access is access String; > > function C_Function (X : in String_Access); > > C_Function(S'Unchecked_Access); > > will sometimes not work because some compilers (and that includes GNAT) > use fat pointers for access to unconstrained arrays (I am not saying > that this is bad). > > so you have to do this instead: > > C_Function(S(S'first)'Unchecked_Access); > > which does not make clear that S is passed as a whole. > > The second problem is that people see a compiler message like "object > has accessibility level deeper than access type" and instead of using > 'Unchecked_Access, they move the declaration to the library level and > create non task safe code. I am not making this up, see the samples > directory that comes with the win32ada binding. Why wouldn't you use: function C_Function ( X : C.char_array ) returns C.Int; -- int c_function ( char* x); pragma Import (C, C_Function); >From my understanding it will be passed by_referrence, ie. as a char * For other record types type Z is record a : C.Int; end record; pragma Convention(C, Z); procedure C_Procedure ( Y : Z ); -- void* c_procedure ( z* y ); pragma Import (C, C_Procedure); David Botton