Open axelriet opened 2 weeks ago
"MaskFlag" is ambiguous. Am I masking out the flag, or masking in the flag? In bitmap graphics, a mask is something that has set bits to represent the bits you want to keep, so my initial guess was that MaskFlag is "remove all flags except the ones in the mask".
"RaiseFlag" sounds like it's raising an exception.
How about WI_WithFlag
and WI_WithoutFlag
?
SetFileAttributes(Path, WI_WithFlag(Attr, FILE_ATTRIBUTE_READONLY)) // Turn on the readonly attribute
SetFileAttributes(Path, WI_WithoutFlag(Attr, FILE_ATTRIBUTE_READONLY)) // Turn off the readonly attribute
Maybe we should also break the WI_ClearFlag
family of macros so that they cannot be used as expressions.
#define WI_ClearAllFlags(var, flags) do { (var) &= ~(flags)); } while ((void)0, 0)
That way if somebody tries
SetFileAttributes(Path, WI_ClearFlag(Attr, FILE_ATTRIBUTE_READONLY)) // Turn off the readonly attribute
they get a build break instead of a mystery variable mutation.
Adding inline bitwise mask/raise macros.
The new macros are meant for inline usage without side effects on the variable. Examples: