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

Add an assert on custom frame control support #4444

Conversation

Mercotui
Copy link
Contributor

This prevents users from getting a attacked by angry frames when they try this example without reading the warnings in the source code.

@@ -27,12 +27,20 @@
********************************************************************************************/

#include "raylib.h"
#include "config.h"
#include "assert.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a system header it should use <> not ""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true 👍

Comment on lines +38 to +42
#if !defined(SUPPORT_CUSTOM_FRAME_CONTROL)
// This examaple requires the SUPPORT_CUSTOM_FRAME_CONTROL feature.
// Please edit your raylib config.h and recompile raylib.
assert(false);
#endif
Copy link
Contributor

@JeffM2501 JeffM2501 Oct 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is assert needed? would not a printf and return -1 here be the same?
assert is not used any other raylib code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside the library assert might be to harsh,
but considering this example application can not function without that define, I would use an assert.

But whatever the codebase follows is fine for me

@raysan5
Copy link
Owner

raysan5 commented Oct 27, 2024

@Mercotui thanks but I'm not adding two extra libraries and an assert just because the user can not read the example instructions.

@raysan5 raysan5 closed this Oct 27, 2024
@Mercotui
Copy link
Contributor Author

Naja as I personally experienced:
running some examples to explore the project,
it is very unpleasant to accidentally run this one.

The whole screen flashes black and white at a high framerate.
Sure, that is the expected result, but it still hurts my eyes.

As for libraries: assert.h is ANSI-C and config.h is from raylib.

Anyway I could update the code to return -1; as Jeff mentioned.

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.

3 participants