Enum type check

Andrew Haley aph@redhat.com
Tue Jun 15 14:33:00 GMT 2010


On 06/15/2010 04:56 AM, naveen yadav wrote:
> Hi all ,
> 
> If we compile attached c file (enum.c), build result is different
> between C & C++ compiler.
> 
> example:
> [naveen@localhost ~]$ gcc enum.c
> [naveen@localhost ~]$ g++ enum.c
> enum.c: In function âint main()â:
> enum.c:13: error: cannot convert âtypeBâ to âtypeAâ in assignment
> [naveen@localhost ~]$

C++ has stronger type checking.  You need

  a= (typeA)B2;

Andrew.



More information about the Gcc-help mailing list