Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utcs!mnetor!seismo!caip!princeton!allegra!alice!ark From: ark@alice.UUCP Newsgroups: net.lang.c Subject: Re: sizeof "string"? multi-line macro usage? Message-ID: <5787@alice.uUCp> Date: Sun, 13-Jul-86 20:43:25 EDT Article-I.D.: alice.5787 Posted: Sun Jul 13 20:43:25 1986 Date-Received: Mon, 14-Jul-86 07:25:13 EDT References: <343@vu-vlsi.UUCP> Organization: Bell Labs, Murray Hill Lines: 21 re: is sizeof("...") legal? > This worked great when > compiled on Pyramid C, VAX VMS C, and Lattice C on a PC. Then I ran into the > Regulus C compiler (Regulus 4.2C) which is truly brain-damaged in many > respects; as far as I can tell, its sizeof returns a random value when given > a string. So is it just Regulus that's screwed up ... ? If you want your code to work on a particular compiler, then the language definition doesn't matter if that compiler doesn't accept it. Thus, although K&R says: A string has type ``array of characters'' ... (p. 181) and When [sizeof is] applied to an array, the result is the total number of bytes in the array. and thus one should conclude that sizeof("...") is legal, that doesn't do you a bit of good if your compiler doesn't like it.