I got that answer from my IBM C/C++ compiler documentation. Maybe IBM is
wrong in your opinion. Structure members are type declarations and hence
storage class specifiers break the rule I laid out. Because you can
change type declarations on the go.
The static storage class specifier can only be applied to the following
names:
* Objects
* Functions
* Class members
* Anonymous unions
You cannot declare any of the following as static:
* Type declarations
* Function declarations within a block
* Function parameters
So it's not so much as you think I'm wrong, but rather that where I got
the answer from is incorrect. Can you imagine trying to do a type
storage class specifier on member inside a structure that you are trying
to cast? Can't be done because of pre-allocated storage. Example is
shared memory on UNIX systems. It's a round peg trying to fit in a
square hole. Ain't going to work.
-- Chris
On Mon, 2007-12-24 at 00:09 +0530, debasish deka wrote:
> In C, a structure member may be of any type except function returning
> some type, any incomplete type, any variably modified type, and void.
> Hence storage class specifiers can break this rule.
> No my friend,
> What I wanted to know is that whether the member element of a
> structure can be assigned static storage classes....but I think after
> some ponderings I got my answer...its like this.....
> " If an element is assigned static storage class, all its objects
> should have that element as static which may not be desirable " -- its
> just my self explaination ...
> Kindly mention if my reasoning is not befitting
> Regards,
> Debasish
> Karmennevaya Dhikaraste, Maaphaaleshu Kadaachanah
> ||
> |
>
> ----- Original Message ----
> From: Christopher Carver <[EMAIL PROTECTED]>
> To: [email protected]
> Sent: Sunday, 23 December, 2007 8:56:10 PM
> Subject: Re: [c-prog] Why are Static Structures not allowed ?
>
> On Sun, 2007-12-23 at 10:22 +0530, debasish deka wrote:
> > Hello All,
> > Sorry for not typing the entire thing on the subject line.
> > I want to know why " The Members of a structure can't have storage
> > class specifiers,
>
> In C, a structure member may be of any type except function returning
> some type, any incomplete type, any variably modified type, and void.
> Hence storage class specifiers can break this rule.
>
> > but Objects of the structure type can, and they apply to all of the
> > members."
>
> In this case objects of a structure is working on the structure, not
> the
> structure members directly.
>
> One of the beautiful complexities of C and C++, that I too got burned
> on
> once. I think (and hence might be wrong) that the language D addresses
> this.
>
> -- Chris
>
> > I tried 'Googling' a few times...but not getting the reason/logic
> for
> > it....
> > Can anyone help me in this ?
> > With regards,
> > Debasish
> >
> > Karmennevaya Dhikaraste, Maaphaaleshu Kadaachanah
> >
> > Unlimited freedom, unlimited storage. Get it now, on
> > http://help. yahoo.com/ l/in/yahoo/ mail/yahoomail/ tools/tools-
> 08.html/
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> >
> >
>
> Get the freedom to save as many mails as you wish. To know how, go to
> http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
>
> [Non-text portions of this message have been removed]
>
>
>
>
>