Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!inmos!bj@europa.inmos.co.uk From: bj@europa.inmos.co.uk (John Honniball) Newsgroups: comp.std.c Subject: Initialisation of Character Arrays Keywords: initialisation Message-ID: <12585@ganymede.inmos.co.uk> Date: 14 Nov 90 18:29:37 GMT Sender: news@inmos.co.uk Reply-To: bj@inmos.co.uk (John Honniball) Organization: INMOS Limited, Bristol, UK. Lines: 26 Consider the following code: static char s1[] = "String One"; static unsigned char s2[] = "String Two"; static signed char s3[] = "String Three"; Just three initialised character arrays, right? Now compile it with GNU C (version 1.36): gcc -c -ansi -pedantic u.c u.c:2: warning: ANSI C forbids string initializer except for `char' elements u.c:3: warning: ANSI C forbids string initializer except for `char' elements So the compiler is complaining about the initialised 'unsigned' and 'signed' character arrays. Paragraph 3.5.7 of the ANSI Standard says: An array of character type may be initialized by a character string literal, optionally enclosed in braces. Successive characters of the character string literal ... initialize the elements of the array. The question is, does the code above comply with the Standard? ________________________________________________________________ | John Honniball (BJ), INMOS Limited, 1000 Aztec West, Bristol | | UK: bj@inmos.co.uk Elsewhere: bj@inmos.com |