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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3869f0598191b11d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!proxad.net!newsfeed.stueberl.de!news-mue1.dfn.de!news-lei1.dfn.de!news.uni-jena.de!not-for-mail From: Adrian Knoth Newsgroups: comp.lang.ada Subject: Re: Porting ADA source Date: 19 Jul 2004 11:09:08 GMT Organization: loris.TV Message-ID: References: NNTP-Posting-Host: ppc201.mipool.uni-jena.de Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fsuj29.rz.uni-jena.de 1090235348 2065 141.35.13.101 (19 Jul 2004 11:09:08 GMT) X-Complaints-To: news@rz.uni-jena.de NNTP-Posting-Date: 19 Jul 2004 11:09:08 GMT User-Agent: slrn/0.9.8.0 (Linux) Xref: g2news1.google.com comp.lang.ada:2228 Date: 2004-07-19T11:09:08+00:00 List-Id: Giacomo Polizzi wrote: First I suggest you should put some kind of email-address in this header. > I have to port an ADA program from an Unix DEC Alpha machine with a DEC ADA > compiler to a Linux pc machine with gnat (gcc) compiler. Second you should realize that it is called "Ada". > The task is to have, if possible, an unique source code compilable on both > platforms but there are the following problems: A solution might be a portable-package. > 1) some system packages that execute the same kind of operations have > different names in the two compilers Write wrappers around it in the portable-package. > 2) some system functions (for example mathematical function) have different > names in the two compilers Write wrappers around it in the portable-package. > 3) the word length is 64 bits on DEC Alpha and 32 bits on pc so it is not > always possible to use the same standard type (for example the long type is > 64 bits on Alpha and 32 bits on pc) Use your own types derived either from the largest type possible (range) or use mod-types. type stuff is mod 2**64; > 4) the standard type (long long) used by gcc on pc to solve the previous > problem is not supported by the DEC ADA compiler Don't rely on any special compiler behaviour, it might not be available on your target. Use the language specification instead. > 5) the different word length modifies some structure length used to define > interface messages with other external programs You lost. It's a well-known drawback in the C-programming language that the memory layout of structs is not defined. Also for Ada it is not specified, but when using representation clauses you can force the compiler to make it your way, thus giving you a common interface. Ergo: you don't know how the compiler, used for compiling the external C-library, arranges the structs in memory. And because you don't know you can't build an Ada-Interface for that. The only thing you can do is to take the headers and the same C-compiler and figure out how it is done for that particular team (tool-chain). You cannot tell how it will behave on different systems. And you'll surely have to put these differences into the portable-package. Keep in mind that different flags used for the C-compiler may result in different memory-layout of your structs. I suggest a complete rewrite of the world with RepClauses ;) -- mail: adi@thur.de http://adi.thur.de PGP: v2-key via keyserver Geht die Sonne auf im Westen, mu�t du deinen Kompa� testen