Declaring struct as static is causing problem.

P

param

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
 
D

Daevaorn

struct new_str { //type cannot be static!
int a;
int b;
};

static new_str a; //declare a static variable
 
P

param

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
 
D

Daevaorn

hmm...
May be this is the solve:

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

Daevaorn

hmm...
May be this can solve problem:

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

Jack Klein

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.
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top