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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,995362da150dc3a9 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!news.motzarella.org!motzarella.org!not-for-mail From: =?ISO-8859-1?Q?S=E9bastien_Morand?= Newsgroups: comp.lang.ada Subject: Re: Interfacing to C and long long data type Date: Thu, 26 Jun 2008 08:53:29 +0000 Organization: A noiseless patient Spider Message-ID: <48635909.8060204@gmail.com> References: <4abde3e1-3c8c-4b01-b63b-d29e7039070b@f36g2000hsa.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: feeder.motzarella.org U2FsdGVkX19EcPYSeV6bNt4OBXYt8HjNSNAbVYIiYxYDLjBpkcpav+zynRglg5Q2v3GnGDj43gbD+TTirObuWbZbxe61TUwko5O6ryXtY5rG6v4gZyXC9cy4TAcnIGyMqD8AenqQ/YoY+vKNB2L/cA== X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Thu, 26 Jun 2008 08:53:37 +0000 (UTC) In-Reply-To: <4abde3e1-3c8c-4b01-b63b-d29e7039070b@f36g2000hsa.googlegroups.com> X-Auth-Sender: U2FsdGVkX18dIZG+ZnZxJcYu3j7IBjeToml5vDY7gPvoiSIC0RnopA== Cancel-Lock: sha1:PALHa3z3RecZ8it/zIlO0N3yOfQ= User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) X-Enigmail-Version: 0.95.6 Xref: g2news1.google.com comp.lang.ada:891 Date: 2008-06-26T08:53:29+00:00 List-Id: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > GNAT already defines Interfaces.Integer_64, so I guess I can use that > as well. I was not sure if it would be fully legal to do so. > Considering the fact that representation of integers in C is largely > left to the implementation, any interoperability is achieved only with > the assumption that the compiler does the right thing, but with GNAT > and the C part compiled with gcc, this should be the case. Anyway when you interface Ada with C, you are loosing the portability of your program, because you are never sure of the size of any type since C definition of type is quite imprecise. Of course standard type match quite well (Int, Long in ada are in the same size of int and long in C) but when you use Integer_64, this is not. So you have to create a configure style program checking the size of you data and using the right one. This is espcially true when using C structure that you have to define by yourself: For instance : struct my_struct { int field1, char* field2, long field3 }; with Interface.C; use Interfaces.C; package Interface.My_Structures is type My_Struct is record Field1: Int; Field2: System.Address; Field3: Long; end record; end Interface.My_Structures; But if you get a new version of my_struct using a new field. You could get core dumped or wrong behaviour : struct my_struct { int field1, char* field2, unsigned int field2_length, long field3 }; So be careful. S�bastien -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) iD8DBQFIY1kJ+zV9xm4PlDQRAuYaAJ40/HEceKuwt2wLp0qOfc+qlBxnegCePNah 4ejBkkzVx/TmfEtzJ2Cc8mg= =LE1d -----END PGP SIGNATURE-----