The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
3answers
33 views

Why is use of an array defined in File1 working in File2 (only declared there),even without “extern”?

Here I have two files externdemo1.c and externdemo2.c.In the first file,I have declared and initialized a character array arr at file scope.But I have declared it in the second file externdemo2.c ...
0
votes
5answers
159 views

What is the use of Static local variable when we can get a global variable at the same cost?

In C ,what is the use of static storage class when an external variable can serve its purpose at the same cost ie. both occupy memory in the data segment of the executable. I have much better scope ...
10
votes
4answers
230 views

can a variable be declared both static and extern?

Why the following doesn't compile? ... extern int i; static int i; ... but if you reverse the order, it compiles fine. ... static int i; extern int i; ... What is going on here?
1
vote
1answer
73 views

_Thread_local storage class specifier in C?

I read a note in the book C How to Program 7th about some new standard C storage class named _Thread_local: The new C standard adds storage class specifier _Thread_local, which is beyond this ...
5
votes
4answers
181 views

What is the difference between “File scope” and “program scope”

A variable declared globally is said to having program scope A variable declared globally with static keyword is said to have file scope. For example: int x = 0; // **program scope** ...
3
votes
1answer
125 views

Is global const pointer to const data guaranteed to be placed in separate read-only section by gcc compiler in c/c++?

Given following definition of global (or static local) variable: static const <type>* const ptr = {&var1, &var2, ...}; , may I rely upon the fact that both ptr and data in initializer ...
0
votes
2answers
73 views

Impact of the type qualifiers on storage locations

As mentioned in the title, I am little confused if the type-qualifiers impact the storage location (stack, bss etc..) of the declarator.To describe more I am considering the following declarations. ...
1
vote
2answers
239 views

Declaration specifiers and declarators

With reference to the question Where in a declaration may a storage class specifier be placed? I started analyzing the concept of declaration-specifiers and declarators. Following is the accumulation ...
14
votes
3answers
350 views

Where in a declaration may a storage class specifier be placed?

For example, let's consider the static storage class specifier. Here are a few examples of both valid and ill-formed uses of this storage class specifier: static int a; // valid int static b; ...
3
votes
2answers
121 views

Stack frame structure for a function with a sub scope

Following is the code, that I took as reference to understand how a sub scope (or) dummy scope (just {}) present within the function, impacts the structure of the stack frame. #include ...
1
vote
4answers
96 views

Is there any possible use of using extern variable in a file that is not included in any other file?

I've encountered many examples on the web, that have extern int x in main.c, where the main function lies. The only use of extern I'm aware of, is to make a declaration in another file, and use it in ...
4
votes
1answer
132 views

How should I use storage class specifiers like ref, in, out, etc. in function arguments in D?

There are comparatively many storage class specifiers for functions arguments in D, which are: none in (which is equivalent to const scope) out ref scope lazy const immutable shared inout What's ...
9
votes
1answer
163 views

What are pure variables?

I was surprised to find that this code compiles: pure string Foo = SomePureFunction(123); pure is only mentioned in the context of functions in the online documentation. What are pure variables, ...
0
votes
3answers
192 views

What storage class is a static inside a function and why?

If I'm using a singleton pattern (yeah, I know - they're usually bad)... and I had an instance function like so: MySingleton* Instance() { static MySingleton instance; return &instance; } ...
0
votes
1answer
702 views

storage class specified for 'FileCase' error

I tried to compile some code however am getting the error storage class specified for 'FileCase' What does this error mean? Does it have to do with the fact I have declared it as an extern int ...

1 2
15 30 50 per page