Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!unmvax!ncar!husc6!bu-cs!encore!bzs From: bzs@Encore.COM (Barry Shein) Newsgroups: comp.windows.x Subject: Re: stupid C question Message-ID: <4552@xenna.Encore.COM> Date: 1 Jan 89 19:41:16 GMT References: <8812300028.AA17754@EXPO.LCS.MIT.EDU> <4543@xenna.Encore.COM> <16124@lll-winken.UUCP> Organization: Encore Computer Corp, Marlboro, MA Lines: 28 In-reply-to: casey@gauss.llnl.gov's message of 31 Dec 88 20:38:02 GMT Posting-Front-End: GNU Emacs 18.41.15 of Tue Jun 9 1987 on xenna (berkeley-unix) > Throughout C, there are in fact more instances of the second than there >are of the first. I can pass "..." as an argument to a function and get >the second interpretation, but not the first for instance. In some ways >interpreting sizeof("...") to be sizeof(char *) would be more consistent, >but certainly less useful. > >Casey Based on that reasoning we would expect for: int a[10]; sizeof(a) to be sizeof(int *)? After all "abcd" is just array of char and calling a subroutine foo(a) passes an int *. Remember, sizeof is NOT A SUBROUTINE, it's an operator and: i = sizeof "foo"; i = sizeof (char *); /* the parens are part of the cast */ are perfectly legal, as is -(i) (ie. you can make unary ops look like subroutines in general, sizeof("foo") just adds gratuitous parens.) Thus, it can have its own semantics, and does, you're looking for consistency where none is needed. -Barry Shein, ||Encore||