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-7-bit Path: g2news1.google.com!news2.google.com!news.maxwell.syr.edu!news.moat.net!lon-transit.news.telstra.net!lon-in.news.telstra.net!news.telstra.net!news-server.bigpond.net.au!53ab2750!not-for-mail From: Dale Stanbrough Newsgroups: comp.lang.ada Subject: Re: Porting ADA source References: User-Agent: MT-NewsWatcher/3.4 (PPC Mac OS X) Message-ID: Date: Mon, 19 Jul 2004 11:04:08 GMT NNTP-Posting-Host: 138.217.18.112 X-Complaints-To: abuse@bigpond.net.au X-Trace: news-server.bigpond.net.au 1090235048 138.217.18.112 (Mon, 19 Jul 2004 21:04:08 EST) NNTP-Posting-Date: Mon, 19 Jul 2004 21:04:08 EST Organization: BigPond Internet Services Xref: g2news1.google.com comp.lang.ada:2227 Date: 2004-07-19T11:04:08+00:00 List-Id: Giacomo Polizzi wrote: > Hello, > > 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. > > The task is to have, if possible, an unique source code compilable on both > platforms but there are the following problems: One solution is to just have a package spec with different bodies for each host. You could inline the code so it wouldn't be any slower. You would have to use your configuration tools to help you choose one or the other. > 1) some system packages that execute the same kind of operations have > different names in the two compilers > 2) some system functions (for example mathematical function) have different > names in the two compilers > > 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) If you use type long_integer, then you could replace any types with new type defined by the range needed. e.g. type my_long_integer is range -2**(63)..2**63-1; Try... with ada.text_Io; use ada.text_Io; procedure demo is type my_long_integer is range -2**(63)..2**63-1; begin Put_line (integer'image (my_long_integer'size)); end; i ran this and got "64" on a 32 bit PPC based mac, so it seems to work. > 4) the standard type (long long) used by gcc on pc to solve the previous > problem is not supported by the DEC ADA compiler see above... > 5) the different word length modifies some structure length used to define > interface messages with other external programs If you need to talk to other programs then you should be defining the size|(range of values) for the fields in the structures without using "long" (or Long_Integer). Define your own types (with size clauses if needed) and then use those in your program. > Is there something like #IFDEF of C language that I can use in ADA ? Not in Ada. Implementations may support a feature like this, but it's not part of the language (e.g. gnat does). Very often you can get around it and have a better structure for your code. > Is there any other kind of solution for the above problems ? > > Thanks to everybody > > Giacomo dale -- dstanbro@spam.o.matic.bigpond.net.au