Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!ucbvax!ucdavis!lll-crg!seismo!brl-tgr!tgr!jeff@isi-vaxa.arpa From: jeff@isi-vaxa.arpa (Jeffery A. Cavallaro) Newsgroups: net.lang.c Subject: Context Variables Message-ID: <230@brl-tgr.ARPA> Date: Mon, 2-Dec-85 18:26:36 EST Article-I.D.: brl-tgr.230 Posted: Mon Dec 2 18:26:36 1985 Date-Received: Thu, 5-Dec-85 05:24:46 EST Sender: news@brl-tgr.ARPA Lines: 35 Recent discussion has pointed out that sizeof(int) does not necessarily == sizeof(char) (what an understatement, blood is still dripping from my VT100...) But, is proper to assume: sizeof(long) >= sizeof(any scalar data type or pointer) Yes, I know you can use a union, but unions have this problem of not being able to be initialized. If this is OK, it is a very handy way to maintain a context variable to ensure reentrancy and other such things. (My specific example...) I am coding a generic capabilities file parser. Each capability item in a definitions is to be described as follows: struct capitem { char *name; /* Name of item */ short type; /* BOOLEAN, STRING, or INTEGER */ long value; /* Discovered value */ long defval; /* Default value */ } The value and defval fields would be able to hold a Boolean, char *, or integer value. When declaring an input buffer, then default values could be statically set, and can be assumed to never change. If this use of long is not valid and unions must be used, then a routine would be needed to set the default values for each new instance of a buffer. I realize that there are other solutions to this problem, but if this use of long is valid, I like this the best. Jeff