Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino.h Defines Macros that Should be Functions #551

Closed
moefrumkin opened this issue Jan 11, 2024 · 1 comment
Closed

Arduino.h Defines Macros that Should be Functions #551

moefrumkin opened this issue Jan 11, 2024 · 1 comment
Assignees

Comments

@moefrumkin
Copy link

#define min(a,b) ((a)<(b)?(a):(b))

This macro and those that follow will lead to unexpected behavior if certain expressions are passed into it. For example,

    int x = 0, y = 1;
    
    printf("Min is: %d", min(++x, ++y));

Will print 2 instead of 1 since the expansion gives the expression ((++x)<(++y)?(++x):(++y)). Is there a reason this shouldn't be a function?

@per1234 per1234 self-assigned this Jan 12, 2024
@per1234 per1234 added the bug label Jan 12, 2024
@per1234
Copy link
Contributor

per1234 commented Jan 12, 2024

Hi @moefrumkin. Thanks for taking the time to submit an issue.

I see we have another report about this at #324.

It is best to have only a single issue per subject so we can consolidate all relevant discussion to one place, so I'll go ahead and close this in favor of the other.

@per1234 per1234 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants