Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utcs!mnetor!seismo!think!caip!brl-adm!brl-smoke!smoke!rbj@icst-cmr From: rbj%icst-cmr@smoke.UUCP Newsgroups: net.lang.c Subject: Re: sizeof \"string\"? multi-line macro usage? Message-ID: <2229@brl-smoke.ARPA> Date: Mon, 14-Jul-86 20:38:21 EDT Article-I.D.: brl-smok.2229 Posted: Mon Jul 14 20:38:21 1986 Date-Received: Tue, 15-Jul-86 06:57:38 EDT Sender: news@brl-smoke.ARPA Lines: 42 Question 1. Is it (portably) legal for sizeof to operate on a string constant? I checked K&R, and they seem to have nothing to say about the subject. Admittedly, string constants are weird because they're the only valid array constants in the language, right? That is, they evaluate to pointers just like other arrays do, but they magically find some memory for themselves, whereas other arrays are only allocated memory when they're declared. This came up because I have coded #define PROMPT "prog> " in an include file, and then later used for (i = 0; i < sizeof(PROMPT) - 1; i++) /* indent to first char of input */ putchar(' '); to get the proper indentation for error messages. Definitely! I have seen `write(1,"Hello World\n",sizeof "Hello World\n")'. Of course, if you want indentation, why not use a tab? Question 2. Does ANSI say anything about macro usage spanning more than one line? Lattice C has something like #define max(a,b) ((a > b) ? a : b) but then barfs when I use the macro over more than one line, like x = min(very-long-expression-here, another-very-long-expression-here); You could always try a backslash after the comma, or use macros for the arguments as well. You're right, it does sound brain damaged. (Root Boy) Jim Cottrell Of course, you UNDERSTAND about the PLAIDS in the SPIN CYCLE --