Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!oliveb!jerry From: jerry@oliveb.UUCP Newsgroups: comp.unix.wizards Subject: Re: Type size problems Message-ID: <1897@oliveb.UUCP> Date: Thu, 9-Jul-87 00:13:25 EDT Article-I.D.: oliveb.1897 Posted: Thu Jul 9 00:13:25 1987 Date-Received: Sat, 11-Jul-87 16:15:27 EDT References: <3659@spool.WISC.EDU> <743@geac.UUCP> Reply-To: jerry@oliveb.UUCP (Jerry F Aguirre) Organization: Olivetti ATC; Cupertino, Ca Lines: 31 In article <1987Jun16.170300.9918@parkridge.uucp> james@parkridge.UUCP (James Sheridan) writes: > Forgive me if this is a little bit naive, but what about having >system-wide constants which tells the compilers (for whichever languages are >available) what the sizes of the objects really are? For example, cc would >know that chars are w bits long, ints are x, shorts are y, and longs are z. It is an interisting idea but I can see one problem. Normally you load your program with a previously compiled library. The routines in the library expect and return values to be of a specific size, not whatever size you requested the compiler to use on your compilation. And of course the system calls have symilar expectations. For example if you have some code that insists that longs must be only 16 bits the compiler should be able to handle this easily. However if your program uses lseek then the arguments are going to be a bit confused. I prefer having new types, defined by some method, that allow a more specific type definition. In this way you can use an "int16" when you must have a 16 bit integer and use a (long) cast if you must pass that to something requiring a long. For less strengent storage you can use a generic long defined to be what is efficient on that system. The remaining problem is that the compiler may not support a type you need. Something like an int12 or an int64 might work on some systems but isn't likely to be available elsewhere. On a related issue; Is anyone familure with a C compiler where int was not the same size as short or long? I mean where short was 16 bits, int was 32, and long was 64. Jerry Aguirre