Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top