- Notifications
You must be signed in to change notification settings - Fork1k
Closed
Description
While developing#997, I wrote some complicated and nested preprocessor statements. I originally tried making them clearer by applying indents, but that was not allowed by the astyle checks, so I removed them again. Now I wonder, should this astyle rule maybe be changed to allow (even if not require) indenting preprocessor directives?
e.g. consider:
#if defined(USBD_ATTACH_PIN)#defineUSBD_PULLUP_CONTROL_PINNAME digitalPinToPinName(USBD_ATTACH_PIN)#defineUSBD_DETACH_LEVEL !(USBD_ATTACH_LEVEL)#elif defined(USBD_DETACH_PIN)#defineUSBD_DETACH_PINNAME digitalPinToPinName(USBD_DETACH_PIN)#defineUSBD_ATTACH_LEVEL !(USBD_DETACH_LEVEL)#elif !USBD_HAVE_INTERNAL_PULLUPS/* When no USB attach and detach pins were defined, and the USB module * also does not have any builtin pullups, assume there is a fixed * external pullup and apply the D+ trick. */#if defined(USE_USB_HS_IN_FS)#defineUSBD_PULLUP_CONTROL_PINNAME USB_OTG_HS_DP#elif defined(USB_OTG_FS)#defineUSBD_PULLUP_CONTROL_PINNAME USB_OTG_FS_DP#else/* USB */#defineUSBD_PULLUP_CONTROL_PINNAME USB_DP#endif/* Detach by writing LOW, but leave floating instead of writing * HIGH to attach. */#defineUSBD_DETACH_LEVEL LOW#defineUSBD_PULLUP_CONTROL_FLOATING#endif/* !defined(USBD_ATTACH_PINNAME) && !USBD_HAVE_INTERNAL_PULLUPS */
vs:
#if defined(USBD_ATTACH_PIN)#defineUSBD_PULLUP_CONTROL_PINNAME digitalPinToPinName(USBD_ATTACH_PIN)#defineUSBD_DETACH_LEVEL !(USBD_ATTACH_LEVEL)#elif defined(USBD_DETACH_PIN)#defineUSBD_DETACH_PINNAME digitalPinToPinName(USBD_DETACH_PIN)#defineUSBD_ATTACH_LEVEL !(USBD_DETACH_LEVEL)#elif !USBD_HAVE_INTERNAL_PULLUPS/* When no USB attach and detach pins were defined, and the USB module * also does not have any builtin pullups, assume there is a fixed * external pullup and apply the D+ trick. */#if defined(USE_USB_HS_IN_FS)#defineUSBD_PULLUP_CONTROL_PINNAME USB_OTG_HS_DP#elif defined(USB_OTG_FS)#defineUSBD_PULLUP_CONTROL_PINNAME USB_OTG_FS_DP#else/* USB */#defineUSBD_PULLUP_CONTROL_PINNAME USB_DP#endif/* Detach by writing LOW, but leave floating instead of writing * HIGH to attach. */#defineUSBD_DETACH_LEVEL LOW#defineUSBD_PULLUP_CONTROL_FLOATING#endif/* !defined(USBD_ATTACH_PINNAME) && !USBD_HAVE_INTERNAL_PULLUPS */
The latter is IMHO alot more readable.
Metadata
Metadata
Assignees
Labels
No labels