Re: flags types/names

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

 



Han-Wen Nienhuys <hanwen@xxxxxxxxxx> writes:

> My questions:
>
> * am I the only one who struggles with the different flavor of `flags` ?

Probably no.

> * if no, what should be done about this? Maybe
>
>   typedef unsigned int ref_flags;
>   #define REF_IS_SYMREF 0x1
>   char *refs_resolve_ref_unsafe(const char *refname, ref_flags *flags, ... );
>
> or
>
>   typedef enum ref_flags {
>      REF_IS_SYMREF = 0x1,
>   };
>   char *refs_resolve_ref_unsafe(const char *refname, enum ref_flags
> *flags, ... );

It is very good to use symbolic constants implemented either as C
preprocessor macros or enums, I would think.

However, I am not enthused to see typedefs; I've never seen multiple
typedefs of the same integral type did anything useful in C.  Perhaps
things are different in the C++ land, but we do not live there.

> A somewhat related gripe is that some code uses `int flags` and other
> code uses `unsigned flags`. It would be great to standardize this.

I agree.  Unless there is very compelling reason to single out the
topmost bit and treat it as special, a set of flag bits should be
"unsigned".



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux