osd7@homxa.UUCP (Orlando Sotomayor-Diaz) (05/30/85)
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c> mod.std.c Digest Thu, 23 May 85 Volume 6 : Issue 12 Today's Topics: string literals Undefined structures ---------------------------------------------------------------------- Date: Thu, 23 May 85 00:23:41 PDT From: ucbvax!geacc022%timevx@cit-hamlet.arpa Subject: string literals To: cbosgd!std-c@BERKELEY decvax!duke!george@idis's proposal: > string-literal: > unit-string-literal > string-literal unit-string-literal > string-literal character-constant If you implement this, please add: character-constant string-literal so that both printf("string" '\n'); /* would become printf("string\n"); */ printf('>' "message"); /* he wants printf(">message"); */ are allowed. I think this fits in well with the string concatenation already added, but it fits into the category of "Nice idea, but not worth the trouble to implement" since you can use double quotes instead of singles and get the desired effect (at the cost of a null byte). Or is there a situation where the single quotes are needed? Gary Ansok GEACC022%TIMEVX @ CIT-HAMLET.ARPA GEA @ CALTECH.BITNET ...ucbvax!cithep!timevx#geacc022 [ Just to keep the record straight, the latest draft (85-045, 4/30/85) describes (C.1.4, p. 20-1) the string literal syntax as: string-literal: "s-char-sequence " opt s-char-sequence: s-char s-char-sequence s-char s-char: any character in the source character set except the double-quote ", backslash \, or new-line character escape-sequence It then adds the following: Description A string literal is a sequence of zero or more characters enclosed in double-quotes, as in "xyz". Constraints A new-line character must not appear in a string literal. The single-quote ' is represented by itself or by the escape sequence \', but the double-quote " must be represented by the escape sequence \"; in addition, the same escape sequences as described for character constants may be used. Semantics A string literal has static storage duration and type "array of const char," and is initialized with the given characters. String literals that are adjacent tokens are concatenated into a single string literal. A NUL character '\0' is then appended. Identical string literals need not be distinct. A string literal is not modifiable. -- Mod -- PS. To promote more up to date contributions to this group and to the Committee, there will be a limited number of copies of the new draft to be distributed. However, I would like to stress that our effort in distributing this should be compensated by you reading it and sending comments to this group and/or members of the committee. Send mail to the moderator and include a line with postal information in the following format: usmail:your name:address line 1:address line 2:address line 3:address line 4 i.e., no more than 5 colons should appear on your address line. The tag usmail: is required, as shown above. Larry Rosler agreed to help on this distribution, so DON'T send mail to him requesting a copy. There are no plans to make the draft available in electronic form. ] ------------------------------ Date: Thu, 23 May 85 12:50:15 edt From: Alan T. Bowler [SDG] <ihnp4!watmath!atbowler> Subject: Undefined structures To: std-c@cbosgd Is the following program in error? I realize that PCC and other compilers will accept it without complaint, furthermore there does exist code that depends on this "feature". My feeling is that such code came into existence by accident and the authors would have not made the error if the compiler had of pointed out the problem. typedef struct { int val; struct st *y; } st; main() { st *p = 0; printf("OOPs\n", p); } There are 2 problems here. The first is that the name "st" is used with 2 different meanings in this program. First as a structure tag and then as a typedef name. I can accept this, but is there a clear statement in the standard that structure tags and typedef names are in independent scopes. K&R is a little vague on this. The second problem is that by the end of the file (compilation unit, module....) the struct with tag "st" is undefined. I realize that it must be possible to declare a pointer to a currently undefined structure type in order that you can build self referencing structures, and mutually referencing structures. However, shouldn't these be resolved by the end of the program? ------------------------------ End of mod.std.c Digest - Thu, 23 May 85 20:40:52 EDT ****************************** USENET -> posting only through cbosgd!std-c. ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C) In all cases, you may also reply to the author(s) above.