* "Incomplete type" and "redefinition" errors in gcc
@ 2003-11-24 15:46 Ashutosh Dixit
2003-11-24 15:56 ` Richard Earnshaw
0 siblings, 1 reply; 5+ messages in thread
From: Ashutosh Dixit @ 2003-11-24 15:46 UTC (permalink / raw)
To: gcc, gcc-help
Hi,
If I compile the following simple C code with gcc:
________________try.c________________________
typedef enum VIDF VIDF;
typedef unsigned int U32;
typedef unsigned int U32;
typedef struct VIDR
{
VIDF VidF;
U32 width;
} VIDR;
typedef enum VIDF
{
aVIDF,
bVIDF
} VIDF;
int main( void )
{
return 0;
}
____________________________________________
I get the following errors:
bash-2.05b$ gcc try.c
try.c:3: error: redefinition of `U32'
try.c:2: error: `U32' previously declared here
try.c:7: error: field `VidF' has incomplete type
try.c:15: error: redefinition of `VIDF'
try.c:1: error: `VIDF' previously declared here
______________________________________________
I would have thought that the code would compile
without errors. Are these bugs or features of gcc (or
of the C language standard) and are there any options
to make these errors disappear?
The preceding is only sample code. In the real code
which I am trying to compile, making changes to take
care of these errors will be very cumbersome.
I am using gcc 3.3.1 on Cygwin.
Thanks very much for your help.
Ashutosh
__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "Incomplete type" and "redefinition" errors in gcc
2003-11-24 15:46 "Incomplete type" and "redefinition" errors in gcc Ashutosh Dixit
@ 2003-11-24 15:56 ` Richard Earnshaw
2003-11-24 16:14 ` Gabriel Dos Reis
0 siblings, 1 reply; 5+ messages in thread
From: Richard Earnshaw @ 2003-11-24 15:56 UTC (permalink / raw)
To: Ashutosh Dixit; +Cc: gcc, gcc-help, Richard.Earnshaw
> Hi,
>
> If I compile the following simple C code with gcc:
> ________________try.c________________________
>
> typedef enum VIDF VIDF;
> typedef unsigned int U32;
> typedef unsigned int U32;
>
> typedef struct VIDR
> {
> VIDF VidF;
> U32 width;
> } VIDR;
>
> typedef enum VIDF
> {
> aVIDF,
> bVIDF
> } VIDF;
>
> int main( void )
> {
> return 0;
> }
> ____________________________________________
>
> I get the following errors:
>
> bash-2.05b$ gcc try.c
> try.c:3: error: redefinition of `U32'
> try.c:2: error: `U32' previously declared here
> try.c:7: error: field `VidF' has incomplete type
> try.c:15: error: redefinition of `VIDF'
> try.c:1: error: `VIDF' previously declared here
All of these diagnostics are correct. You can't repeat typedefs, and you
can't instantiate a forward declaration of an enum.
R.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "Incomplete type" and "redefinition" errors in gcc
2003-11-24 15:56 ` Richard Earnshaw
@ 2003-11-24 16:14 ` Gabriel Dos Reis
2003-11-24 22:48 ` Ashutosh Dixit
0 siblings, 1 reply; 5+ messages in thread
From: Gabriel Dos Reis @ 2003-11-24 16:14 UTC (permalink / raw)
To: Richard.Earnshaw; +Cc: Ashutosh Dixit, gcc, gcc-help
Richard Earnshaw <rearnsha@arm.com> writes:
| > Hi,
| >
| > If I compile the following simple C code with gcc:
| > ________________try.c________________________
| >
| > typedef enum VIDF VIDF;
| > typedef unsigned int U32;
| > typedef unsigned int U32;
[...]
| All of these diagnostics are correct. You can't repeat typedefs, and you
| can't instantiate a forward declaration of an enum.
I see the original poster was mentioning C. However, I just wanted to
add that in C++, it is permitted to repeat a typedef declaration
provided it binds the same tokens. The enum forward declaration
restrictions are same in both languages.
-- Gaby
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "Incomplete type" and "redefinition" errors in gcc
2003-11-24 16:14 ` Gabriel Dos Reis
@ 2003-11-24 22:48 ` Ashutosh Dixit
0 siblings, 0 replies; 5+ messages in thread
From: Ashutosh Dixit @ 2003-11-24 22:48 UTC (permalink / raw)
To: Gabriel Dos Reis, Richard.Earnshaw; +Cc: Ashutosh Dixit, gcc, gcc-help
Richard/Gabriel,
Thanks very much for replying. The program does
compile under MSVC.NET - I guess we should consider
that as non-standard MS extensions to the language...
Thanks,
Ashutosh
__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
^ permalink raw reply [flat|nested] 5+ messages in thread
* "Incomplete type" and "redefinition" errors in gcc
@ 2003-11-22 7:57 Ashutosh Dixit
0 siblings, 0 replies; 5+ messages in thread
From: Ashutosh Dixit @ 2003-11-22 7:57 UTC (permalink / raw)
To: gcc-help
Hi,
If I compile the following simple C code with gcc:
________________try.c________________________
typedef enum VIDF VIDF;
typedef unsigned int U32;
typedef unsigned int U32;
typedef struct VIDR
{
VIDF VidF;
U32 width;
} VIDR;
typedef enum VIDF
{
aVIDF,
bVIDF
} VIDF;
int main( void )
{
return 0;
}
____________________________________________
I get the following errors:
bash-2.05b$ gcc try.c
try.c:3: error: redefinition of `U32'
try.c:2: error: `U32' previously declared here
try.c:7: error: field `VidF' has incomplete type
try.c:15: error: redefinition of `VIDF'
try.c:1: error: `VIDF' previously declared here
______________________________________________
I would have thought that the code would compile
without errors. Are these bugs or features of gcc and
are there any options to make these errors disappear?
The preceding is only sample code. In the real code
which I am trying to compile, making changes to take
care of these errors will be very cumbersome.
I am using gcc 3.3.1 on Cygwin.
Thanks very much for your help.
Ash
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-11-24 22:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-24 15:46 "Incomplete type" and "redefinition" errors in gcc Ashutosh Dixit
2003-11-24 15:56 ` Richard Earnshaw
2003-11-24 16:14 ` Gabriel Dos Reis
2003-11-24 22:48 ` Ashutosh Dixit
-- strict thread matches above, loose matches on Subject: below --
2003-11-22 7:57 Ashutosh Dixit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).