Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ucla-cs!zen!ucbvax!decvax!ima!haddock!karl From: karl@haddock.UUCP Newsgroups: comp.lang.c Subject: Re: Does ANSI C have lengthof() ? Message-ID: <1152@haddock.ISC.COM> Date: Wed, 16-Sep-87 21:00:33 EDT Article-I.D.: haddock.1152 Posted: Wed Sep 16 21:00:33 1987 Date-Received: Sat, 19-Sep-87 05:37:56 EDT References: <1265@mhres.UUCP> <6700012@iaoobelix.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 28 In article <6700012@iaoobelix.UUCP> wagner@iaoobelix.UUCP writes: >I don't expect any preprocessor to know about the sizes of certain types. >This can cause strange and weird confusions if you use cpp e.g. for CProlog >programs (like me) or for other types of non-C text pre-processing purposes. >Knowledge about sizes of data objects definitely belongs to the semantics of >the language C, and cannot be handled by a generic cpp! Actually, the usual implementation of cpp already knows a lot about the *syntax* of C -- comments, single quotes, double quotes, and backslash. Thus, it is not a "generic" preprocessor -- if you feed it if str = "\" then call dochar(BACKSLASH) endif (where BACKSLASH is a token that should be expanded, and the language is one that does not use the backslash character as an escape) it will almost certainly do the wrong thing. Also, knowledge about the sizes of types shouldn't cause the confusion you imply -- the only place the preprocessor would use this information is to resolve directives like "#if (sizeof(int) > 2)", which you would probably not be using in your non-C program. In fact, the existing directive "#if (0 < 1-2-3)" does the "wrong" thing if I'm using cpp to preprocess APL, because C semantics are used to evaluate preprocessor expressions. (Having said all this, I should remark that I do not think the preprocessor should know more about C. I agree with the conclusion but not the argument.) Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint