Re: enum types and casting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Apr 29, 2007 at 11:10:26AM +0530, Shriramana Sharma wrote:

> 1. Are enums allowed as types only in C++ and not in C?

They are part of ANSI C.


> gcc rejects using an enum as a type whereas g++ accepts it.

Not really.  You need to say "enum BODY body".


> When the target enum of the cast contains no name that has the same
> integer value as the value being casted, how does g++ accept the cast?
> Is this expected behaviour or a bug?

You are doing C style casts here, which you shouldn't.
The compiler will warn you at best, but in the end he will handle
everything as raw bytes.

  Leslie

-- 
Personal homepage: https://viridian.dnsalias.net/~sky/homepage/
gpg --keyserver pgp.mit.edu --recv-keys DD4EBF83

Attachment: pgp7eWf497JYq.pgp
Description: PGP signature


[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux