The relevant BNF from the ANSI C spec (and if I screw my analysis up, my
apologies...it's been a long time since I've analyzed a language spec, and
I can't even be sure I'm using the terminology correctly)...
The syntax for a declaration with initializer from 6.5:
declarator = initializer
One initializer from 6.5.7:
assignment-expression
And if you trace backwards through the spec all the way to 6.3.1, you find
that one valid assignment-expression is a primary-expression:
identifier
constant
string-literal
( expression )
And under "Semantics":
A parenthesized expression is a primary expression. Its type and value
are identical to those of the unparenthesized expression.
So, the short answer is that yes, placing the string literal in
parentheses looks like valid ANSI C.
-John
On 5 Feb 2000, Niels M�ller wrote:
> If I understood this correctly, the problem is that the system
> compiler on IRIX doesn't accept
>
> static const char msg[] = ("hello");
>
> If so, changing the definition to
>
> #define N_(x) x
>
> should solve the problem.
>
> I'm not sure if the IRIX behaviour is proken. Does ANSI-C allow array
> initializers in parenthesis? Like
>
> char s[] = ("foo");
> int a[] = ( {1, 2, 3} );
>
> /Niels
>
>