When/Where does 'global static' come from?

Z

Zhigang Cui

Hi,
When I saw 'global static', the first response was there was no such term.
But I realized it's an idiom later. When we learn C language, when we study
C standard, when we study compiler, we use 'linkages of identifiers',
'storage-class specifier'. One of my friends said maybe we could use 'local
static', :)

Who could tell me when/where 'global static' came from? Are there some other
similar idioms?

Thanks in advance.
 
J

Jack Klein

Hi,
When I saw 'global static', the first response was there was no such term.

Your first response was correct. There is no such term in the C
standard. The word 'global' does not exist in the C standard.
But I realized it's an idiom later. When we learn C language, when we study
C standard, when we study compiler, we use 'linkages of identifiers',
'storage-class specifier'. One of my friends said maybe we could use 'local
static', :)

A better idea is not to promote the use of sloppy terminology. It
causes confusion and can lead to errors in understanding.
Who could tell me when/where 'global static' came from? Are there some other
similar idioms?

I haven't the faintest idea where it came from, anymore than I have
any idea where 'void main()' came from. Other than it comes from
people who haven't learned the correct terminology.

Where I am from, students who go into fields that might involve
programming study in programs with names like 'computer engineering'
or 'computer science'. I don't know of any other field of engineering
or science where sloppy or imprecise terminology is encouraged or even
tolerated.
Thanks in advance.

Another such misuse is 'implicit cast'. A cast operator requests the
compiler to perform an conversion which might or might not be
performed automatically in the absence of the cast operator. There
can be no such thing as an 'implicit cast', there can be an automatic
conversion without a cast operator.

I find this annoying enough when technical writers use the phrase.
When I saw it in the output of a static code checking tool, written by
people who should understand the language standard, it considerably
lowered my opinion of that tool.
 
E

Emmanuel Delahaye

Zhigang Cui said:
When I saw 'global static', the first response was there was no such
term. But I realized it's an idiom later. When we learn C language, when
we study C standard, when we study compiler, we use 'linkages of
identifiers', 'storage-class specifier'. One of my friends said maybe we
could use 'local static', :)

Who could tell me when/where 'global static' came from? Are there some
other similar idioms?

Variables have a last two properties known as

- duration: bloc, permanent.
- scope: bloc, compile unit without external linkage, compile unit with
external linkage

-> A variable defined in a bloc has a bloc duration and a bloc scope.

-> A variable defined in a bloc with the static qualifier has a permanent
duration and a bloc scope.

-> A variable defined out of a function has a permanent duration and a
compile unit with external linkage scope.

-> A variable defined out of a function with the static qualifier has a
permanent duration and a compile unit without external linkage scope.

The case of the allocated variables is a little bit more complex. The scope
is, say, undefined, but the allocated block is accessible one or aliased
pointers.

As long as the object has been sucessfully created (*alloc()), the duration
is permanent. It ceased at the moment when the object is deleted (free()).
 
D

Darrell Grainger

Hi,
When I saw 'global static', the first response was there was no such term.
But I realized it's an idiom later. When we learn C language, when we study
C standard, when we study compiler, we use 'linkages of identifiers',
'storage-class specifier'. One of my friends said maybe we could use 'local
static', :)

Who could tell me when/where 'global static' came from? Are there some other
similar idioms?

When you declare a variable it has scope and it has linkage. If you
declare the variable outside any function or block it has file scope. If
it external linkage then the variable is 'visible' to all parts of the
program. It is available 'globally'. Just as in English, if I say that
Coca Cola is available globally I mean that it is available everywhere.

The ISO and ANSI standards never use the term 'global' to describe the
scope of a variable. They call this file scope.

When you think about it, a static variable declared at file scope no
longer becomes 'global'. Thus the term 'global static' becomes an
oxymoron. English is full of oxymorons but the C standard is not.

The proper term for 'global static' is 'file scope, internal linkage'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,192
Latest member
KalaReid2

Latest Threads

Top