Declarators are fun!

2006-01-07 01:23:00 -08:00

I was reading the C99 standard (because, you know, I’m Bored) and found a couple of interesting tidbits. Read on and see…

6.7.6[3]:

EXAMPLE The constructions

  1. int
  2. int *
  3. int *[3]
  4. int (*)[3]
  5. int (*)[*]
  6. int *()
  7. int (*)(void)
  8. int (*const [])(unsigned int, ...)

name respectively the types (a) int, (b) pointer to int, (c) array of three pointers to int, (d) pointer to an array of three ints, (e) pointer to a variable length array of an unspecified number of ints, (f) function with no parameter specification returning a pointer to int, (g) pointer to function with no parameters returning an int, and (h) array of an unspecified number of constant pointers to functions, each with one parameter that has type unsigned int and an unspecified number of other parameters, returning an int.

6.7.5.3[16]:

EXAMPLE 1 The declaration

int f(void), *fip(), (*pfi)();

declares a function f with no parameters returning an int, a function fip with no parameter specification returning a pointer to an int, and a pointer pfi to a function with no parameter specification returning an int. …

See also part II.

Leave a Reply

Do not delete the second sentence.