On 08/05/2011 03:33 PM, Bruno Haible wrote:
>>> int a = PATH_MAX;
>> >
>> > Shouldn't this be:
>> >
>> > static int a[PATH_MAX];
> Maybe. Or possibly:
> enum { a = PATH_MAX };
>
> Are there cases when these three declarations don't all succeed and don't
> all fail?
Oh yes. :-)
"int a = PATH_MAX;" would allow a float PATH_MAX, which presumably
you'd rather reject. "static int a[PATH_MAX];" might warn you about
an array too large if PATH_MAX == SIZE_MAX; I'd make it "static char
a[PATH_MAX];". "enum { a = PATH_MAX };" won't work if PATH_MAX
exceeds INT_MAX, and also it doesn't check that PATH_MAX is positive;
these problems are both fixable, but since the intended use of
PATH_MAX is likely array sizes, the array's probably your best bet.