471,599 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

Declaring struct as static is causing problem.

Declaring struct as static is creating problem with newer version of CC
compiler 5.7 in solaris.

e.g.

static struct new_str {
int a;
int b;
};

It shows the Error : "static" is not allowed here.

Pls help me out of this problem. Also what is the significance of
declaring type as static ....as is shown above for new type new_str.

Regards
Parminder

Jan 13 '06 #1
5 2099
struct new_str { //type cannot be static!
int a;
int b;
};

static new_str a; //declare a static variable

Jan 13 '06 #2
hi Daevaorn ,

That's true that type cannot be static. But this code was working fine
with earlier compiler
i.e. CC 4.2. I want to know what was the benefit of declaring "static
struct" at that time.

May be it was that :
1.) static was used so that it has global visiblity only in the
declaration file.
2.) or was it declared with the notion that declaring static struct
will force all the variables of this type to be initialized with
defailt values.

I don't know i am confused. what was the significance of declaring it
that way.

Regards
Parminder

Jan 13 '06 #3
hmm...
May be this is the solve:

struct new_str {
int a;
int b;
} var; // that code works fine

Jan 13 '06 #4
hmm...
May be this can solve problem:

struct new_str {
int a;
int b;
} var; // that code works fine

Jan 13 '06 #5
On 13 Jan 2006 01:07:26 -0800, "param" <dh******@gmail.com> wrote in
comp.lang.c++:
hi Daevaorn ,

That's true that type cannot be static. But this code was working fine
with earlier compiler
i.e. CC 4.2. I want to know what was the benefit of declaring "static
struct" at that time.


There was no benefit, it's just that the compiler had a defect, so
someone wrote sloppy code that did not generate a diagnostic.

--
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.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jan 15 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Bryan Parkoff | last post: by
8 posts views Thread by Pent | last post: by
10 posts views Thread by athanasios.silis | last post: by
5 posts views Thread by Hallvard B Furuseth | last post: by
24 posts views Thread by Daniel Rudy | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.