Discussion:
[Mingw-users] "declaration does not declare anything"
Clint Smullen
2004-02-28 14:29:06 UTC
Permalink
Under MinGW GCC 3.2.3, the following style of code compiles without errors:

struct element {
union {
struct {
...
} box;
};
};

But, under 3.3.1 and the current 3.3.3 candidate, I get the following error:

warning: declaration does not declare anything

and most of the rest of my code fails to build because of this. I have
been unable to find any information about this language feature being
removed, or any other information about why this error occurs from either
the MinGW site or the FSF site. Thanks for any help.

- Clint Smullen
Benjamin Riefenstahl
2004-02-28 14:52:01 UTC
Permalink
Hi Clint,
Post by Clint Smullen
struct element {
union {
struct {
...
} box;
};
};
But, under 3.3.1 and the current 3.3.3 candidate, I get the
warning: declaration does not declare anything
I think this is what is usually called an "anonymous union". It is a
VC++ compiler extension, but not allowed in standard C (at least C89),
or rather it means a different, useless thing. I'm not sure if this
is in C99 or C++.

benny
Mikael Aronsson
2004-02-28 15:37:02 UTC
Permalink
I can't see why it fails, the message is a warning not an error.

Mikael

----- Original Message -----
From: "Benjamin Riefenstahl" <***@epost.de>
To: <mingw-***@lists.sourceforge.net>
Sent: Saturday, February 28, 2004 5:38 PM
Subject: Re: [Mingw-users] "declaration does not declare anything"
Post by Benjamin Riefenstahl
Hi Clint,
Post by Clint Smullen
struct element {
union {
struct {
...
} box;
};
};
But, under 3.3.1 and the current 3.3.3 candidate, I get the
warning: declaration does not declare anything
I think this is what is usually called an "anonymous union". It is a
VC++ compiler extension, but not allowed in standard C (at least C89),
or rather it means a different, useless thing. I'm not sure if this
is in C99 or C++.
benny
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
MinGW-users mailing list
https://lists.sourceforge.net/lists/listinfo/mingw-users
Benjamin Riefenstahl
2004-02-28 15:53:07 UTC
Permalink
Hi Mikael,
Post by Mikael Aronsson
Post by Clint Smullen
warning: declaration does not declare anything
I can't see why it fails, the message is a warning not an error.
I assume the warning means that the compiler thinks that there was a
type mentioned but no actual data item named, which in turn would mean
that the compiler will ignore the declaration. I doubt that that is
what was meant by the programmer.

benny
Gisle Vanem
2004-02-28 14:56:02 UTC
Permalink
Post by Clint Smullen
struct element {
union {
struct {
...
} box;
};
};
warning: declaration does not declare anything
Anonymous unions is a C++ thingy. Name the union something.

--gv
Greg Chicares
2004-02-28 16:46:03 UTC
Permalink
Post by Clint Smullen
struct element {
union {
struct {
...
} box;
};
};
warning: declaration does not declare anything
and most of the rest of my code fails to build because of this.
Why does a warning prevent code from building?
Post by Clint Smullen
I have
been unable to find any information about this language feature being
removed, or any other information about why this error occurs from either
the MinGW site or the FSF site.
Google for the exact diagnostic message:
"declaration does not declare anything"
to see hundreds of links. Narrow the search by adding
regression
or
"anonymous union"
and you'll find '-fms-extensions' suggested. See C++98 9.5/2.
Clint Smullen
2004-02-28 18:12:09 UTC
Permalink
Post by Greg Chicares
Why does a warning prevent code from building?
A warning prevents building because it causes GCC to ignore that whole
declaration, causing a massive cascade of errors. But, yes, after looking
up more particular information on "anonymous unions", it is a feature of
the C++ standard, not of the C standard, though as much as I have read, the
standard does not restrict that behavior, it seems it was just a change of
mind of the GCC developers to disable this behavior for C code. Sad
really, since it improves the readability of code greatly.

- Clint Smullen

Loading...