[lkml]   [2005]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: Use enum to declare errno values
    I'm going to regret jumping in on this.

    On Sat, 2005-12-03 at 01:07 +0800, Coywolf Qi Hunt wrote:
    > 2005/12/3, Bill Davidsen <>:
    > > 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.

    Hmm, I like to use a lot of both enums and macros (defines). I use
    defines mostly for general constants and emums for enumerations.
    Although it can be argued that errno should be enums, I would prefer
    them as macros. Especially since they then can be used in asm. (.S

    I seldom use enums for kernel programming though. I use it just to
    define a list of numbers where I don't care what their value is (usually
    for transition states). I use defines when I do. Because errno does
    depend on the value (for glibc to figure them out too) then I think
    defines are better.

    But in user space programming I use enums more often than defines,
    because gdb can convert the number into a name. So instead of seeing
    x=0x1234 I see x=FOO.

    -- Steve

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-12-02 18:54    [W:0.021 / U:8.520 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site