Re: scratch memory



Jordan Abel wrote:
On 2006-02-11, pete <pfiland@xxxxxxxxxxxxxx> wrote:

Mark McIntyre wrote:
<snip>
C has no concept of "main memory" or "fast memory". What C /does/ have
is differing durations and differing scopes.

"scope" comes in two flavours of interest, file-scope, which most
people think of as global, and block-scope. The latter refers to
variables declared inside functions or inside blocks inside functions,
ie somewhere between a { and a }.

Parameters in function prototypes have function prototype scope,
and parameters in old style function definitions
have function scope.

What scope do parameters in function prototypes that are part of a [new
style] function definition have?

Block scope.

"function prototype scope" appears at
first glance to mean that they're not in scope in the function body.

Yep.

C99, 6.2.1#4

"[...] If the declarator or type specifier that declares
the identifier appears inside a block or within the list
of parameter declarations in a function definition, the
identifier has block scope, which terminates at the end
of the associated block. If the declarator or type
specifier that declares the identifier appears within
the list of parameter declarations in a function
prototype (not part of a function definition), the
identifier has function prototype scope, which
terminates at the end of the function declarator. [...]"

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
.



Relevant Pages

  • Re: types, variable names and fields
    ... No, assuming the same scope, no two typedefs, objects, or functions ... determine what declaration an identifier refers to. ... For structure/union tags and members, ... declarator or type specifier). ...
    (comp.lang.c)
  • Re: Accessing local variable
    ... char * fun ... "4 Every other identifier has scope determined by the placement of its ... declaration (in a declarator or type specifier). ...
    (comp.lang.c)
  • Re: Portability regarding sizeof() function
    ... Appropriate use of sizeof is essential to writing portable code. ... That seems to define the end of the scope. ... Every other identifier has scope determined by the ... placement of its declaration (in a declarator or type ...
    (comp.lang.c)
  • Re: declaration shadows a parameter
    ... be a mistake to do so, but the only who knows that it is a mistake is the one who wrote the code. ... declared before the opening '{' of the scope. ... A label name is the only kind of identifier that has function scope. ... declaration (in a declarator or type specifier). ...
    (comp.lang.c)
  • Re: declaration shadows a parameter
    ... about its diagnostics.) ... If the declarator or type specifier that declares the identifier ... declarations in a function definition, ... I think this means that the scope of the parameter is the outer block ...
    (comp.lang.c)