0

In case of declaration;

const int *p;

specifier const is applied to int i.e, the object p points to.
while regarding the statement(JUNE 1998, EMBEDDED SYSTEMS PROGRAMMING);

Some declaration specifiers do not contribute to the type of the declarator-id.Rather, they specify other semantic information that applies directly to the declarator-id. For example, in:

static unsigned long int *x[N];

the keyword static does not apply to the unsigned long int objects that the pointers in x point to. Rather, it applies to x itself:

 ---------------------------   
/    \                    / \ 
static unsigned long int * x [N];

This declares that x is a static object of type “array of N elements of pointer to unsigned long int.”

I do not understand why static applied to x?

haccks
  • 104,019
  • 25
  • 176
  • 264
  • 1
    Can you imagine to apply `static` to `unsigned long int*` but not to `x`? If answer is "no" then order doesn't matter because `static` and `const` are two different things. In the case of `const` it's different: `const int* p` is not the same as `int* const p`. – Adriano Repetti Jul 18 '13 at 21:09
  • What would you expect it to be applied to? – Jim Rhodes Jul 18 '13 at 21:13
  • 2
    The variable `x` has array type (this is the `unsigned long *[n]` part, more precisely it is an array of `n` pointers to unsigned long. However `static` has nothing to do with types: it denotes the *storage class* of `x` (others are `extern`, `auto` and `register`). You may want to read other books if you find this one unclear (it seems unclear to me too), see eg. http://stackoverflow.com/questions/562303/the-definitive-c-book-guide-and-list – Alexandre C. Jul 18 '13 at 21:17
  • @AlexandreC. Yes you are right. Sorry for asking such a stupid question. – haccks Jul 18 '13 at 21:19
  • @AlexandreC.; Ya. That's why I was confused. But now it is clear. – haccks Jul 18 '13 at 21:21

2 Answers2

1

static doesn't make sense to apply to the type. static applies to the storage location / visibility of x ( depending where its declared )

Keith Nicholas
  • 43,549
  • 15
  • 93
  • 156
1

Storage-class specifiers and type qualifiers are completely different things. The type qualifier (const, volatile, or restrict) is part of the type, whereas storage-class specifiers (typedef, extern, static, auto, or register) are part of the declaration.

If you're referring to C99, see 6.7.1 Storage-class specifiers and 6.7.3 Type qualifiers.

R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711