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

bitWrite macro incorrectly expands ternary operator #5714

Closed
Labels
Architecture: AVRApplies only to the AVR microcontrollers (Uno, etc.) Architecture: SAMApplies only to the SAM microcontrollers (Due) Architecture: SAMDApplies only to the SAMD microcontrollers (Zero, etc.) Type: Bug
@svatoun

Description

let's have a bitWrite(data, bitIndex, computedValue == 5 ? 1: 0);

bitWrite macro definition lacks parenthesis around the `bitvalue' parameter, so it expands as follows

(computedValue == 5 ? 1 : 0 ? bitSet(value, bit) : bitClear(value, bit))

and the `0 ? bitSet...' is then compiled as the false branch of the ternary operator in the passed expression.
Please correct the definition as follows:

#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit))

(parenthesis added)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Architecture: AVRApplies only to the AVR microcontrollers (Uno, etc.) Architecture: SAMApplies only to the SAM microcontrollers (Due) Architecture: SAMDApplies only to the SAMD microcontrollers (Zero, etc.) Type: Bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /