Search code examples
cpointersqualifiers

I do not understand why the qualifier static applied to x here?


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?


Solution

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