This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc rejects enum/int compatibility


Thank you for your response.

On Mon, 2014-12-29 at 16:05 -0400, Edwin Pujols wrote:
> >   extern enum { red, green, blue } foo;
> >   int foo = green;
> > ...
> > ...
> > Please explain me what is wrong.
> 
> You are declaring `foo' twice, 

This is correct, because 'foo' has external linkage.

> this works:
> 
> extern enum { red, green, blue } foo;
> 
> int bar = green;
> 
> int main(void)
> {
>   printf("bar = %d\n", bar);
>   return 0;
> }
> 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]