Skip to content

Improve mocks of builtin macros #133

Closed
@ianfixes

Description

@ianfixes

A post to the arduino developers' mailing list suggests a smarter way to do macros for (e.g.) max using "statement expressions":

#define max(a,b) \
  ({ typeof (a) _a = (a); \
      typeof (b) _b = (b); \
    _a > _b ? _a : _b; })

Adopting this will prevent double-evaluating a and b if for some reason they themselves are expressions with side effects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arduino mocksCompilation mocks for the Arduino libraryenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions