Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow indenting preprocessor macros? #1006

Closed
@matthijskooijman

Description

@matthijskooijman

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp