Groups | Search | Server Info | Login | Register
Groups > comp.lang.c.moderated > #527
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!newspump.sol.net!post2.nntp.sol.net!posts.news.megabitz.net!nnrp2-asbnva.megabitz.net!not-for-mail |
|---|---|
| From | Toni Homedes i Saun <toni.homedes@gmail.com> |
| Newsgroups | comp.lang.c.moderated |
| Subject | switch (long long) standard? |
| Date | Tue, 1 Apr 2014 01:50:00 -0500 (CDT) |
| Organization | Usenet Fact Police |
| Sender | clcm@herd.plethora.net |
| Approved | clc@plethora.net |
| Message-ID | <clcm-20140401-0005@plethora.net> (permalink) |
| Mime-Version | 1.0 |
| Complaints-To | groups-abuse@google.com |
| X-Google-dkim-signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=path:newsgroups:date:complaints-to:injection-info:nntp-posting-host :user-agent:mime-version:message-id:subject:from:injection-date:to :content-type; bh=IxrJF3QHo32PAY+3W57VhakHgtsp5XkvUU6U58Ehnag=; b=XIGofWKBwelQpNPxHwoeOeh5EuYZInltwREbc9WU7+Gzv44ORCuxnODfkmijxZJUfm 5BmWFrqPDTVavYBLsOysDIIaLiv3JmXf0sRpPp6bKxx/owUkSa63aEvaA1ta6dqeCoYg FgmgWvYjjBHVbtPpBP2Gt1OUsRZhVao0PFH4PZsawPCnvYkbpBgnEfyYQqtFCqAlg3Co 8q6fpsM8K+lruIbM2PPljARo+eWd3MOVmbbPe+qwx9R10YdSzWNqBaUwzJdgGd0MfI7z VZ0GRJQGhJfG8PC7Y82IX6fEkPNfZfL9bA1MvbZ3kSFC2cNT3AF/qJTNpmVtpKjgUVqV 3ykQ== |
| Delivered-To | comp-lang-c-moderated@moderators.isc.org |
| User-Agent | G2/1.0 |
| Return-Path | <news@google.com> |
| X-Received | by 10.182.120.9 with SMTP id ky9mr99816obb.15.1391084151646; Thu, 30 Jan 2014 04:15:51 -0800 (PST) |
| Injection-Date | Thu, 30 Jan 2014 12:15:51 +0000 |
| X-Original-to | clcm@plethora.net |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=213.151.108.194; posting-account=ZzgkFQoAAACDfeu8_qoWa-i_Upk0xbFA |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Lines | 34 |
| NNTP-Posting-Date | 01 Apr 2014 06:12:30 GMT |
| NNTP-Posting-Host | 12edb30e.news.megabitz.net |
| X-Trace | DXC=C@:Z[D]<R4YHS?F8nl6a1X><6FU_Q:4mR^W\Y;gN2lO]\gBU5Bnb0b^R:hQd`I4ZSP7d@DE\31QYUe4?]5YdC<jSF7O[G=28e_USd`QB_\FNaT=@;I<AW>[@U |
| X-Complaints-To | abuse@megabitz.net |
| X-Received-Bytes | 3090 |
| X-Received-Body-CRC | 3934255103 |
| Xref | csiph.com comp.lang.c.moderated:527 |
Show key headers only | View raw
Hi,
While developing a state machine compiler I came to a point where I would like the state machine to do a switch() based on current state + event, both being enums.
Would it be portable and standards compliant to do something similar to
enum states { ...... } current_state;
enum events { ...... } received_event;
#define INT_BITS (CHAR_BIT * sizeof (int))
#define mix(a,b) (((unsigned long long) (a)) << INT_BITS | (b))
.
.
.
switch (mix(current_state, received_event)) {
case mix(foo, bar) :
.....
break;
}
I don't have access to the standards so I can't check my assumptions but I understand that an enum is actually an int and that I need, at minimum, a long long to hold the value of two ints side by side. Is this correct?
And, what I really don't know, is if switch () can work on any size integral type or only on int
Thanks for any help
--
Toni
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Back to comp.lang.c.moderated | Previous | Find similar
switch (long long) standard? Toni Homedes i Saun <toni.homedes@gmail.com> - 2014-04-01 01:50 -0500
csiph-web