linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: leslie.polzer@gmx.net
To: Shriramana Sharma <samjnaa@gmail.com>
Cc: Linux C Programming List <linux-c-programming@vger.kernel.org>
Subject: Re: enum types and casting
Date: Fri, 4 May 2007 13:26:53 +0200	[thread overview]
Message-ID: <20070504112653.GB11947@wintermute.farpoint> (raw)
In-Reply-To: <46342FCA.1090400@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 748 bytes --]

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 #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2007-05-04 11:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-29  5:40 enum types and casting Shriramana Sharma
2007-05-04 11:26 ` leslie.polzer [this message]
2007-05-04 12:18 ` Steve Graegert
2007-05-16 18:37   ` Shriramana Sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070504112653.GB11947@wintermute.farpoint \
    --to=leslie.polzer@gmx.net \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=samjnaa@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).