Skip to content

Prevent some macro pitfalls#17956

Merged
thinkyhead merged 3 commits intoMarlinFirmware:bugfix-2.0.xfrom
espr14:patch-2
May 12, 2020
Merged

Prevent some macro pitfalls#17956
thinkyhead merged 3 commits intoMarlinFirmware:bugfix-2.0.xfrom
espr14:patch-2

Conversation

@espr14
Copy link
Contributor

@espr14 espr14 commented May 11, 2020

Description

If you call an argument in macro more than once it could cause side effect due to calling function that change global state like n++. Evaluating these functions at beginning solves the issue.

Benefits

Makes macros safe to be called with a function as an argument.

@thinkyhead thinkyhead changed the base branch from 2.0.x to bugfix-2.0.x May 12, 2020 04:35
Co-Authored-By: espr14 <espr14@users.noreply.github.com>
@thinkyhead
Copy link
Member

Unfortunately, some of these macros need to function in the preprocessor.

@thinkyhead thinkyhead closed this May 12, 2020
@thinkyhead thinkyhead reopened this May 12, 2020
@thinkyhead thinkyhead changed the title Update macros.h Prevent some macro pitfalls May 12, 2020
@thinkyhead thinkyhead merged commit ab19a27 into MarlinFirmware:bugfix-2.0.x May 12, 2020
@espr14 espr14 deleted the patch-2 branch May 12, 2020 07:45
vgadreau pushed a commit to vgadreau/Marlin that referenced this pull request May 29, 2020
Co-authored-by: espr14 <espr14@users.noreply.github.com>
jmp0x0000 pushed a commit to jmp0x0000/Marlin that referenced this pull request Aug 7, 2020
Co-authored-by: espr14 <espr14@users.noreply.github.com>
njibhu pushed a commit to njibhu/Marlin that referenced this pull request Aug 24, 2020
Co-authored-by: espr14 <espr14@users.noreply.github.com>
HairingX pushed a commit to HairingX/Marlin that referenced this pull request Jun 16, 2021
Co-authored-by: espr14 <espr14@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants