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

Safer NK_LEN macro #467

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Safer NK_LEN macro #467

wants to merge 2 commits into from

Conversation

ryuukk
Copy link
Contributor

@ryuukk ryuukk commented Jun 14, 2022

Protects from division by 0 and when used from <= C11

https://stackoverflow.com/a/1598827

@aganm
Copy link
Contributor

aganm commented Jun 16, 2022

C++ sizeof will never return 0.

From C++ standard, 9/3 "Classes": "Complete objects and member subobjects of class type shall have nonzero size."

@dumblob
Copy link
Member

dumblob commented Jun 16, 2022

IMHO if the new macro helps in some real cases or for some compilers, then we can merge this. Any such examples @ryuukk ?

@N-R-K
Copy link

N-R-K commented Jun 29, 2022

C++ sizeof will never return 0.

Neither will C. The lowest addressable unit is defined to be char which will always be 1 byte. And you cannot apply sizeof to a bit-field.

@ryuukk
Copy link
Contributor Author

ryuukk commented Oct 28, 2022

Sorry i didn't meant "and when used from C++"

I meant when used with a <= C11 compiler, it'll refuse to compile

@riri
Copy link
Contributor

riri commented Nov 13, 2023

Looks ok to me too

Just missing nuklear.h build and version bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants