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

Fail fast on invalid null arguments #239

Open
ChrisThrasher opened this issue Mar 14, 2024 · 0 comments
Open

Fail fast on invalid null arguments #239

ChrisThrasher opened this issue Mar 14, 2024 · 0 comments
Labels

Comments

@ChrisThrasher
Copy link
Member

ChrisThrasher commented Mar 14, 2024

Macros like CSFML_CALL aim to be friendly to users who incorrectly pass NULL to a parameter that expects a non-null argument. In some cases this results in functions that return placeholder values or short-circuit their logic to avoid a null pointer deref. What I like about this approach is that it results in well-defined behavior in all build types.

What I propose instead is a simpler approach where we eliminate most macros in Internal.h in favor of a simpler CSFML_ASSERT macro that terminates the program (perhaps with a helpful log message) when invalid null arguments are found. I'd rather users be notified ASAP that their code is incorrect than CSFML make attempts to gracefully handle code that users should have never written in the first place.

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

No branches or pull requests

2 participants