Newsgroups: comp.lang.lisp
From: Kaz Kylheku <k...@kylheku.com>
Date: Fri, 21 Sep 2012 19:13:00 +0000 (UTC)
Subject: Re: Why I Hate C
On 2012-09-21, kalvin.n...@gmail.com <kalvin.n...@gmail.com> wrote:
> torstai, 20. syyskuuta 2012 18.36.26 UTC+3 Nick Keighley kirjoitti:
Yes there is a problem. What are you daft?
>> > typedef enum >> > { >> > BITMASK_1 = 0x01, >> > BITMASK_2 = 0x02, >> > BITMASK_3 = 0x04} >> > Bitmask; >> #define BIT(N) (1 << (N))
> This typedef is just fine. Its intention is to declare a enumerated constant
The enumerated type has three values in its domain: BITMASK_1, BITMASK_2
Yet the code uses that type to represent it:
Bitmask x = BITMASK_1 | BITMASK_2;
What that means is that x now has a value which is not one of the declared
Note that this was banished from C++ long ago, because C++ was given
That's one good reason to write your C in such a way that it also compiles with
You cannot use enumerations for bitmasks, period. It's conceptually wrong,
>> > typedef enum
No it is not fine, because now you have constants ONE, TWO, and THREE >> > { >> > ONE, >> > TWO, >> > THREE} >> > Number; >> well yes I admit i'd puke over that one. Everyon knows its > This is just fine as well. The intention is to declare enumerated constants
whose values are 0, 1 and 2, respectively. I suggest you read a C tutorial.
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||