Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #5840 > unrolled thread
| Started by | Ya Shou <zxyzxy12321@gmail.com> |
|---|---|
| First post | 2011-06-11 06:11 -0700 |
| Last post | 2011-06-13 14:39 +0000 |
| Articles | 3 on this page of 63 — 27 participants |
Back to article view | Back to comp.lang.c
a doubt about c Ya Shou <zxyzxy12321@gmail.com> - 2011-06-11 06:11 -0700
Re: a doubt about c James Kuyper <jameskuyper@verizon.net> - 2011-06-11 09:36 -0400
Re: a doubt about c Angel <angel+news@spamcop.net> - 2011-06-11 14:37 +0000
Re: a doubt about c Keith Thompson <kst-u@mib.org> - 2011-06-11 11:55 -0700
Re: a doubt about c Angel <angel+news@spamcop.net> - 2011-06-11 20:41 +0000
Re: a doubt about c Ian Collins <ian-news@hotmail.com> - 2011-06-12 08:58 +1200
Re: a doubt about c Shao Miller <sha0.miller@gmail.com> - 2011-06-11 17:09 -0500
Re: a doubt about c Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-11 18:25 -0400
Re: a doubt about c Ian Collins <ian-news@hotmail.com> - 2011-06-12 11:43 +1200
Re: a doubt about c Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-06-12 05:38 -0700
Re: a doubt about c Roberto Waltman <usenet@rwaltman.com> - 2011-06-12 10:12 -0400
Re: a doubt about c Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-12 10:59 -0400
Re: a doubt about c Nobody <nobody@nowhere.com> - 2011-06-15 17:07 +0100
Re: a doubt about c Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-06-12 11:33 -0700
Re: a doubt about c James Kuyper <jameskuyper@verizon.net> - 2011-06-15 09:53 -0400
Re: a doubt about c Dr Nick <3-nospam@temporary-address.org.uk> - 2011-06-16 18:46 +0100
Re: a doubt about c DSF <notavalid@address.here> - 2011-06-11 18:53 -0500
Re: a doubt about c Keith Thompson <kst-u@mib.org> - 2011-06-11 16:18 -0700
Re: a doubt about c Stephen Sprunk <stephen@sprunk.org> - 2011-06-11 21:13 -0500
Re: a doubt about c Ian Collins <ian-news@hotmail.com> - 2011-06-12 14:56 +1200
Re: a doubt about c Keith Thompson <kst-u@mib.org> - 2011-06-11 20:24 -0700
Re: a doubt about c Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-12 08:10 -0400
Re: a doubt about c Ian Collins <ian-news@hotmail.com> - 2011-06-12 11:49 +1200
Re: a doubt about c Keith Thompson <kst-u@mib.org> - 2011-06-11 15:36 -0700
Re: a doubt about c Nobody <nobody@nowhere.com> - 2011-06-12 00:23 +0100
Re: a doubt about c Seebs <usenet-nospam@seebs.net> - 2011-06-13 14:39 +0000
Re: a doubt about c Squeamizh <squeamz@hotmail.com> - 2011-06-15 15:44 -0700
Re: a doubt about c Geoff <geoff@invalid.invalid> - 2011-06-15 19:57 -0700
Re: a doubt about c "J. J. Farrell" <jjf@bcs.org.uk> - 2011-06-16 18:39 +0100
Re: a doubt about c Nobody <nobody@nowhere.com> - 2011-06-17 15:39 +0100
Re: a doubt about c Willem <willem@toad.stack.nl> - 2011-06-17 14:49 +0000
Re: a doubt about c Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-17 09:14 -0600
Re: a doubt about c Shao Miller <sha0.miller@gmail.com> - 2011-06-17 12:00 -0500
Re: a doubt about c Shao Miller <sha0.miller@gmail.com> - 2011-06-17 11:08 -0500
Re: [OT] Doubt vs. question. (Re: a doubt about c) Shao Miller <sha0.miller@gmail.com> - 2011-06-17 13:00 -0500
Re: [OT] Doubt vs. question. (Re: a doubt about c) Shao Miller <sha0.miller@gmail.com> - 2011-06-22 19:01 -0500
Re: a doubt about c Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-17 09:14 -0600
Re: a doubt about c Seebs <usenet-nospam@seebs.net> - 2011-06-17 22:16 +0000
Re: a doubt about c "J. J. Farrell" <jjf@bcs.org.uk> - 2011-06-18 02:24 +0100
Re: a doubt about c Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-11 23:09 -0600
[OT] Doubt vs. question. (Re: a doubt about c) Roberto Waltman <usenet@rwaltman.com> - 2011-06-12 10:05 -0400
Re: [OT] Doubt vs. question. (Re: a doubt about c) Keith Thompson <kst-u@mib.org> - 2011-06-12 11:22 -0700
Re: [OT] Doubt vs. question. (Re: a doubt about c) Ben Pfaff <blp@cs.stanford.edu> - 2011-06-12 11:44 -0700
Re: [OT] Doubt vs. question. (Re: a doubt about c) Ralph Spitzner <rasp@spitzner.org> - 2011-06-13 11:31 +0200
Re: [OT] Doubt vs. question. (Re: a doubt about c) James Kuyper <jameskuyper@verizon.net> - 2011-06-15 10:03 -0400
Re: [OT] Doubt vs. question. (Re: a doubt about c) Dr Nick <3-nospam@temporary-address.org.uk> - 2011-06-17 07:52 +0100
Re: [OT] Doubt vs. question. (Re: a doubt about c) Michael Press <rubrum@pacbell.net> - 2011-06-19 00:41 -0700
Re: [OT] Doubt vs. question. (Re: a doubt about c) James Kuyper <jameskuyper@verizon.net> - 2011-06-19 07:04 -0400
Re: [OT] Doubt vs. question. (Re: a doubt about c) Bill Waddington <william.waddington@beezmo.com> - 2011-06-23 11:03 -0700
Re: a doubt about c Shao Miller <sha0.miller@gmail.com> - 2011-06-11 11:23 -0500
Re: a doubt about c pete <pfiland@mindspring.com> - 2011-06-11 13:56 -0400
Re: a doubt about c "dr.oktopus" <blindwilly@freeonline.zzn.com> - 2011-06-11 12:53 -0700
Re: a doubt about c Lew Pitcher <lpitcher@teksavvy.com> - 2011-06-11 16:01 -0400
Re: a doubt about c Keith Thompson <kst-u@mib.org> - 2011-06-11 13:07 -0700
Re: a doubt about c Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-11 14:13 -0600
Re: a doubt about c Nobody <nobody@nowhere.com> - 2011-06-11 23:31 +0100
Re: a doubt about c pete <pfiland@mindspring.com> - 2011-06-11 20:07 -0400
Re: a doubt about c Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-11 23:05 -0600
Re: a doubt about c Shao Miller <sha0.miller@gmail.com> - 2011-06-11 16:42 -0500
Re: a doubt about c "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2011-06-11 14:23 -0700
Re: a doubt about c Shao Miller <sha0.miller@gmail.com> - 2011-06-11 17:27 -0500
Re: a doubt about c Keith Thompson <kst-u@mib.org> - 2011-06-11 15:42 -0700
Re: a doubt about c Seebs <usenet-nospam@seebs.net> - 2011-06-13 14:39 +0000
Page 4 of 4 — ← Prev page 1 2 3 [4]
| From | Shao Miller <sha0.miller@gmail.com> |
|---|---|
| Date | 2011-06-11 17:27 -0500 |
| Message-ID | <it0mk7$cum$1@dont-email.me> |
| In reply to | #5859 |
On 6/11/2011 4:23 PM, christian.bau wrote: > On Jun 11, 10:42 pm, Shao Miller<sha0.mil...@gmail.com> wrote: > >> If that conclusion holds as true and your statement that the behaviour >> is undefined holds as true, then I think that there could be no signed >> integer values that are not representable as 'signed char'. What do you >> think? > > It's the shift operation by itself that would be undefined. For > example, if int has 32 bits then any shift of a signed or unsigned int > by 32 or more bits is undefined. If an int has CHAR_BIT bits, then any > shift of a signed or unsigned int by CHAR_BIT or more bits is > undefined. I absolutely agree and thought that I stated as much. The point was that it's in a macro, so it's not 'int', it's 'intmax_t' and that means that 'CHAR_BIT' is not only the maximum width of any integer type, but the precise width of any integer type. I could be wrong about that, but I don't think so.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-06-11 15:42 -0700 |
| Message-ID | <lnzklo7zy8.fsf@nuthaus.mib.org> |
| In reply to | #5861 |
Shao Miller <sha0.miller@gmail.com> writes:
> On 6/11/2011 4:23 PM, christian.bau wrote:
>> On Jun 11, 10:42 pm, Shao Miller<sha0.mil...@gmail.com> wrote:
>>
>>> If that conclusion holds as true and your statement that the behaviour
>>> is undefined holds as true, then I think that there could be no signed
>>> integer values that are not representable as 'signed char'. What do you
>>> think?
>>
>> It's the shift operation by itself that would be undefined. For
>> example, if int has 32 bits then any shift of a signed or unsigned int
>> by 32 or more bits is undefined. If an int has CHAR_BIT bits, then any
>> shift of a signed or unsigned int by CHAR_BIT or more bits is
>> undefined.
>
> I absolutely agree and thought that I stated as much. The point was
> that it's in a macro, so it's not 'int', it's 'intmax_t' and that means
> that 'CHAR_BIT' is not only the maximum width of any integer type, but
> the precise width of any integer type. I could be wrong about that, but
> I don't think so.
I think you're right.
The macro definition is:
#define ALL_ONES_CHAR ((1<< CHAR_BIT) - 1)
If it's used as an expression, it's of type int (because 1 is of
type int). But if it's used in the controlling expression of a #if,
it acts as if it were of type intmax_t.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-06-13 14:39 +0000 |
| Message-ID | <slrnivc4mh.1sqt.usenet-nospam@guild.seebs.net> |
| In reply to | #5840 |
On 2011-06-11, Ya Shou <zxyzxy12321@gmail.com> wrote: > I read some open source c program code, found a problem that let me doubt. The word "doubt" is used, in most dialects of English, only when you have been told something but do not believe it. It is not generally used for other kinds of uncertainty. > All those programs are using macros to define constants, and did > not use an enum to achieve, but I think in the enumeration constants > is very convenient. > Enumeration defines constants used in c++, but not seen any in c, why? History, mostly. Enumerations can be used for constants in C, but a lot of people never got the habit. The C language existed before enumerated types existed, so a lot of people picked up the convention of using macros for constants. Also, macros can be used for non-integer constants, or constants larger than an object of type int can hold, while enumerations are more limited. -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [standalone]
Page 4 of 4 — ← Prev page 1 2 3 [4]
Back to top | Article view | comp.lang.c
csiph-web