Afficher un message
Vieux 12/04/2008, 05h59   #4
Jack Klein
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: the static identifier in the global scope

On Fri, 11 Apr 2008 01:46:45 -0700 (PDT), "parag_paul@hotmail.com"
<parag_paul@hotmail.com> wrote in comp.lang.c:

> hi All
> for the following
>
> #include <stdio.h>
> typedef struct{
> int a ;
> int b[100];
> char* j;
> } AST;
>
> static AST a;


First, C does not have anything called a "global scope". The snipped
you have shown, if it were compiled, has the definition of an unnamed
structure type, the definition of an alias for that type, and the
definition of an object of this structure type with internal linkage,
all at "file scope", which is the largest scope that C has.

Secondly, even if there is no other definition of that structure type
in other translation units, there still could be another identifier
named "a" with external linkage in other translation units, which
could cause a problem if the static keyword is removed from the object
definition, giving this identifier "a" external linkage.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
  Réponse avec citation
 
Page generated in 0,07743 seconds with 9 queries