Re: Use enum to declare errno values

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

 



Coywolf Qi Hunt wrote:

2005/12/3, Bill Davidsen <[email protected]>:
Coywolf Qi Hunt wrote:

This is a reason why enums are worse than #defines.

Unlike in other languages, C enum is not much useful in practices.
Actually they are highly useful if you know how to use them. They allow
type checking, have auto increment, and are part of the language instead
 of a feature of the preprocessor.

Yes, I know type checking and auto increment. But they are not
worthwhile, at least not for serious C programming. No, I don't know
how to use them comfortably.

Type checking is not useful for serious C programming? Really?

What's wrong with sorted macros? They are more flexible and readable.
enums just look weird. We also share macros b/w C and asm.

You words on language and preprocessor doesn't make any sense.

They highlight the difference. The preprocessor is a form of text editor, which only knows what the source *says* but not what it *means*. The compiler knows about types, common subexpressions, etc.

It's not a feature of the preprocessor, it's what cpp is for. Look, I
call it Cpp. Without this `feature', what would a C preprocessor do?
You've castrated cpp.

Follow you logic, C standard should only specify C language, not
anything of libc...  I have no interest in arguing the relations b/w C
and cpp.

The standard should specify the source language and it's meaning. The fact that it specifies what cpp does (text editing) as well is for convenience. The language works the same whether you write it with vi or cpp, cpp is just more convenient that sed ;-)

Maybe the designer wanted C to be as fancy as other languages?  C
shouldn't have had enum imho. Anyway we don't have any strong motives
to switch to enums.
The last sentence seems correct in spite of your misunderstanding of how
and why enums are used and useful. Like a driver who mis-read a map
wandering aimlessly and lost, you have come to the correct destination
by accident.

lol

It would have been good to use enums in the first place, I can't see
changing now because of the effort involved.

You contradict yourself rather.

Not at all... enum would have been better, but not so much better that it's worth doing over.

--
bill davidsen <[email protected]>
 CTO TMR Associates, Inc
 Doing interesting things with small computers since 1979

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux