Re: Missing braces around {0} initializer?!

I

Ike Naar

Then again, there's another way to do this, though it requires
an extra declaration:

const static struct s struct_s_zero;
struct s s1 = struct_s_zero;

This is good for another warning :-(
a.c:1: warning: `static' is not at beginning of declaration
 
P

Peter Nilsson

[email protected] (Ike Naar) said:
This is good for another warning :-(
a.c:1: warning: `static' is not at beginning of declaration

It's a constraint violation in fact, since storage class
specifiers must precede type qualifiers in declarations.
 
P

Phil Carmody

This is good for another warning :-(
a.c:1: warning: `static' is not at beginning of declaration

It doesn't need to be. I like warnings from compilers to keep
tabs on some style issues, but that looks pointlessly pedantic.

Phil
 
B

Ben Bacarisse

Peter Nilsson said:
It's a constraint violation in fact, since storage class
specifiers must precede type qualifiers in declarations.

I can't see where. Can you give a reference? The standard includes
(in footnote 315) the following example:

const static double one_third = 1.0/3.0;

which suggests otherwise.
 
K

Keith Thompson

Phil Carmody said:
It doesn't need to be. I like warnings from compilers to keep
tabs on some style issues, but that looks pointlessly pedantic.

C99 6.11.5:

The placement of a storage-class specifier other than at the
beginning of the declaration specifiers in a declaration is an
obsolescent feature.

A warning seems reasonable to me. (And I should have compiled the
code, with maximum warnings, before posting it.)
 
P

Peter Nilsson

I can't see where.  Can you give a reference?

It's been marked obsolescent since C89. I was under the mistaken
impression that it actually had been removed.
 The standard includes
(in footnote 315) the following example:

  const static double one_third = 1.0/3.0;

which suggests otherwise.

Which I see is in N1425 as footnote 340. So it's obsolescent,
but not discouraged!
 
B

Ben Bacarisse

Peter Nilsson said:
It's been marked obsolescent since C89. I was under the mistaken
impression that it actually had been removed.

And I did not know it was marked as obsolescent, so it was useful post
all around.
Which I see is in N1425 as footnote 340. So it's obsolescent,
but not discouraged!

Another example was posted recently from the rationale. It's almost
being encouraged!
 
P

Phil Carmody

Keith Thompson said:
C99 6.11.5:

The placement of a storage-class specifier other than at the
beginning of the declaration specifiers in a declaration is an
obsolescent feature.

A warning seems reasonable to me. (And I should have compiled the
code, with maximum warnings, before posting it.)

Ah, the 'future' section, indeed. (Aside - it seems odd that that
section is normative, given that it refers to nothing tangible.)
Thanks for that anyway.

Phil
 

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,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top