A
arkmancn
Any comments? thanks.
Jim
Jim
Please put your question in the body of your post and don't SHOUT.Any comments? thanks.
Any comments? thanks.
Any comments? thanks.
Any comments? thanks.
Jim
Any comments? thanks.
Any comments? thanks.
James Kuyper Jr. said:The keyword 'static' has many meanings in C, none of which make sense
inside a struct. C++ gave that keyword an additional meaning, which
applies only in that context, but this newsgroup is for discussing C,
not C++.
Richard said:It would make perfect sense to see static in a struct as far as I can
see. What is so nonsensical about it? Or is your point not that it
wouldn't make sense, but that it's simply not available?
James Kuyper Jr. said:The standard defines (at least) three different meanings for the
keyword static, depending upon whether it's at file scope, block
scope, or function prototype scope. A single struct type, once
defined, could be used to declare an object in any of those scopes, so
the possible meaning of the 'static' keyword when applied to a member
would have to change with the scope.
File scope: what would it mean for a structure object to have external
linkage, but a member of that object to have internal linkage (or vice
versa)?
Block scope: What would it mean for a structure object to be
automatically or dynamically allocated, and to have a member that was
statically allocated (or vice versa)?
Function prototype scope: the only meaning currently provided for
static in this scope is that it requires that the leading dimension of
an array passed as a specific argument to the function to be at least
as long as the length specified for the corresponding parameter. I
don't see how that could be applied to struct members.
I'm not saying that answers couldn't be invented for these questions;
I'm merely saying that any answer would be a new invention, not a
simple extension to the currently defined meanings of 'static'.
James said:Richard wrote:
The standard defines (at least) three different meanings for the
keyword static, depending upon whether it's at file scope, block
scope, or function prototype scope. A single struct type, once
defined, could be used to declare an object in any of those scopes, so
the possible meaning of the 'static' keyword when applied to a member
would have to change with the scope.
File scope: what would it mean for a structure object to have external
linkage, but a member of that object to have internal linkage (or vice
versa)?
Block scope: What would it mean for a structure object to be
automatically or dynamically allocated, and to have a member that was
statically allocated (or vice versa)?
santosh said:James Kuyper Jr. wrote: ....
Presumably that the static member is invisible to other modules?
Presumably that the static member retains it's previous value?
Presumably that the static member is invisible to other modules?
Presumably that the static member retains it's previous value?
Richard said:....
I'm not sure I follow you. The "meaning" seems clear enough to me. All
structures share a common field value across all instances of that
structure.
I'm not sure anything you have said means that it doesn't "make sense"
for "static" to mean something reasonable inside a structure. The fact
that it isn't part of C is neither here nor there to the conversation
about a hypothetical thing anyway.
James Kuyper said:That's obvious only by reference to C++; it's not in any sense a
uniquely obvious extension of any of the current meanings of 'static'
in C.
Richard said:We would have to beg to differ. It appears fairly clear to me what would
be meant by a static structure field if such existed in C.
James Kuyper said:Can you point to one of the existing meanings for 'static' in C, and
explain how this is a unique natural extension of that meaning? It
seems quite different from any of the three that I listed.
Richard said:I already did. It's above.
I also pointed out that I am not talking about any "existing
documentation of static", just that it does not take a degree in CS to
come to a relatively easy deduction of what a static field in a struct
*might* mean in some alternative universe.
Possibly you have a much more detailed view of what static might mean
- but in my mind its fairly straightforward and clear in the,
possibly, simplistic ways in which I have used it and/or understood
it.
> I'm not sure I follow you. The "meaning" seems clear enough to me. All
> structures share a common field value across all instances of that
> structure.
Richard said:I'm not sure I follow you. The "meaning" seems clear enough to me. All
structures share a common field value across all instances of that
structure.
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.