Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!hcr!parkridge!james From: james@parkridge.UUCP Newsgroups: comp.unix.wizards Subject: Type size problems Message-ID: <1987Jun16.170300.9918@parkridge.uucp> Date: Tue, 16-Jun-87 17:03:00 EDT Article-I.D.: parkridg.1987Jun16.170300.9918 Posted: Tue Jun 16 17:03:00 1987 Date-Received: Wed, 17-Jun-87 03:41:42 EDT References: <3659@spool.WISC.EDU> <743@geac.UUCP> <4679@columbia.UUCP> <420@elxsi.UUCP> <1124@copper.TEK.COM> <12670@topaz.rutgers.edu> Reply-To: james@parkridge.UUCP (James Sheridan) Organization: Parkridge Computer Systems Inc., Oakville, Ontario, Canada Lines: 57 Checksum: 60074 In article <12670@topaz.rutgers.edu> hedrick@topaz.rutgers.edu.UUCP writes: >Unfortunately in C (as most other languages) there is no distinction >between how you describe variables to be used within your program and >how you describe external objects. The result is that network code ... >pointers. But if we are to have any hope of writing portable network >code, there has to be some way to say that something is a 16 or 32 >bit object. Currently short and long are it. Anybody have a better >idea? The only alternative I can think of is to use long:16 and >long:32. Presumably that would continue to work if longs expanded. 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. All the user would have to do would be to set up defines (or whatever) that request a minimum and maximum size for the objects required and make sure that these constraints are followed strictly within his/her code. When the compiler went at it, it would see the requested sizes and make sure that it could satisfy them on the current machine while still following the K&R rules. If it couldn't, it would scream. For example.... #define MIN_CHAR 8 /* Minimum sizes required, max are optional */ #define MAX_CHAR 8 /* Compiler has free reign to shift about */ #define MIN_SHORT 8 /* sizes within the limits imposed here... */ #define MAX_SHORT 16 #define MIN_INT 8 #define MAX_INT 16 #define MIN_LONG 16 Anyone have any reasons why this sort of thing wouldn't work?? This is just off the top of my head, but it seems reasonable if you really want portable code and are prepared to put more work into it..... ___________________________________________________________________________ | | _____ | | | James R. Sheridan | | \ | ..utzoo!parkridge!pcssun!james | | | |__/ | | | Parkridge Computer Systems Inc. | |/ \ | | | 710 Dorval Drive, Suite 115 | \_/\_ | YOU can help wipe out COBOL in | | Oakville, Ontario, CANADA | \ | our lifetime!! | | L6K 3V7 (416) 842-6873 | \_/ | | |_________________________________|________|________________________________| -- ___________________________________________________________________________ | | _____ | | | James R. Sheridan | | \ | ..utzoo!parkridge!pcssun!james | | | |__/ | | | Parkridge Computer Systems Inc. | |/ \ | | | 710 Dorval Drive, Suite 115 | \_/\_ | YOU can help wipe out COBOL in | | Oakville, Ontario, CANADA | \ | our lifetime!! | | L6K 3V7 (416) 842-6873 | \_/ | | |_________________________________|________|________________________________|