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: 109fba,4873305131bf4d94 X-Google-Attributes: gid109fba,public X-Google-Thread: 1014db,4873305131bf4d94 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,4873305131bf4d94 X-Google-Attributes: gid103376,public From: "Samuel T. Harris" Subject: Re: Porting Experiences (was Ada and Pascal etc ) Date: 1997/11/05 Message-ID: <3460A7BB.3CCD27DC@hso.link.com>#1/1 X-Deja-AN: 287222756 References: <34557f2b.1934172@news.mindspring.com> <345BB35E.4488@dynamite.com.au> <63ftj9$r9g@bgtnsc02.worldnet.att.net> <345E3ACD.A15@gsg.eds.com> <63mcmm$r3s$1@helios.crest.nt.com> Organization: Hughes Training Inc. - Houston Operations Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++ Date: 1997-11-05T00:00:00+00:00 List-Id: Reading the arguments between Kaz and others, I'm struck with the realization that Kaz is missing a significant point. As long as application code is not concerned with the representation of variables, Kaz is correct in his statements that a few simple guidelines insure good type choices for portable C code. What Kaz has failed to consider, but has been state by others, is that sometimes the representation of the type IS important to the application, or at least to the context in which the application is running. The classic example here is a 32-bit integer. While application usually are only concerned witht he RANGE supported by the type (and Kaz's guidelines do insure a proper choice of type) the context in which the app is running may force the use of a 32-bit integer, especially when interfacing to hardware, COTS libraries, or in a distributed environment where heterogenous architectures must interface with each other. These are common examples of the context forcing a representation. C does not support forcing the representation in a portable way. Ada does. The need for such cannot be simply dismissed because the need is real. In fact, Ada provides me facilities to exactly map the representation of a record right down to the location and size of each field to conform to the requirements of memory-mapped hardware registers. This is very powerful and convenient. I can even use this facility to insure the record structures across different hardware/compiler combination are compatible and simply send the records themselves over the interface with little or no pre/post processing. With Ada, I can force a particular variable to sit upon a particular address without any cumbersome intermediate pointer. This is how I place my exactly constructured record variable on top of the actual memory area where the hardware has placed its registers. While it is true that support for these facilities is optional and can involve implementations specific limitations, in practise, commercial compilers do in fact support these facilities to a great degree. Such concerns simply become requirements as to compiler selection. All compilers which support these facilities (which is indeed nearly all compilers I've used) will represent said structures in exactly the same manner because the repsentation clauses leave no room for interpretation. Hence my specific machine, operating system, nor compiler affects my portability since my source remains invariant across all there of these variations. So, I can't say to Kaz that he is wrong, because he is not, as far as he goes. What I do say to Kaz is "You have only pricked the tip of the portability iceberg." Portability involves much more than guaranteeing the base range of types. Code with specific ranges and specific representations (including size and layout) must also be portable, especially with the rise of distributed computing and the integration of COTS products with custom code. C simply does not have the language features to support any but the most rudimentary porting requirements of single-machine, black-box applications that run by themselves or with others in a strictly homogeneous environment all of which are built with a strictly compatible set of tools. Any variation in the above, rather limiting set of circumstances, forces the C developer to address many considerations to insure proper type choice. Issues which simply do not concern me when I'm using Ada. -- Samuel T. Harris, Senior Engineer Hughes Training, Inc. - Houston Operations 2224 Bay Area Blvd. Houston, TX 77058-2099 "If you can make it, We can fake it!"