sja@sirius.hut.fi (Sakari Jalovaara) (01/20/91)
How about: typedef char typename; int f (int (typename [])); Is "f" compatible with int f (int func (char arr[])); or int f (int arr[]); ? 3.5.4.3 has a rule on "a single typedef name in parenthesis." With some imagination "typename[]" might be regarded as "a single typedef name" (but how about "int g (int (* typename));" then -- would "* typename" also be a single typedef name?) I tried two compilers that claim to be standard-conforming and they disagreed on this... ++sja
gwyn@smoke.brl.mil (Doug Gwyn) (01/20/91)
In article <1991Jan19.171622.22801@santra.uucp> sja@sirius.hut.fi (Sakari Jalovaara) writes: >How about: > typedef char typename; > int f (int (typename [])); >Is "f" compatible with > int f (int func (char arr[])); >or > int f (int arr[]); I wish I understood your example.. What the standard means is that "if an identifier in such contexts CAN be taken as a typedef name, then it SHOULD be taken as a typedef name". And, yes, this has ramifications for parsers.
sja@sirius.hut.fi (Sakari Jalovaara) (01/22/91)
> I wish I understood your example.. I meant this: /tmp (vipunen) 28> cat t1.c typedef char typename; int f (int (typename [])); int f (int func (char arr[])); /tmp (vipunen) 29> cc -c t1.c 4 | int f (int func (char arr[])); ....a......................... a - 1506-132: (S) Illegal redeclaration of function, f. /tmp (vipunen) 30> cat t2.c typedef char typename; int f (int (typename [])); int f (int arr[]); /tmp (vipunen) 31> cc -c t2.c /tmp (vipunen) 32> i.e. is "int (typename [])" an abstract declarator or redundant parenthesis around a declarator. > What the standard means is that "if an identifier in such contexts > CAN be taken as a typedef name, then it SHOULD be taken as a typedef name". Yep, that clears it; the compiler I use above seems to have it wrong. ++sja