Skip to content

[utils] fix const warning with SaveFileText callback #4938

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

Merged
merged 2 commits into from
May 13, 2025

Conversation

JeffM2501
Copy link
Contributor

The SaveFileTextCallback does not take it's second argument as a const char*, this is not the same as the argument the caller passes in in SaveFileText function, this generates a warning in gcc.

../external/raylib-master/src/utils.c: In function 'SaveFileText':
../external/raylib-master/src/utils.c:416:43: warning: passing argument 2 of 'saveFileText' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  416 |             return saveFileText(fileName, text);
      |                                           ^~~~
../external/raylib-master/src/utils.c:416:43: note: expected 'char *' but argument is of type 'const char *'

This PR changes the callback signature to match. This should not change binary compatibility since const is not used at runtime. The argument should be const as the callback can not modify the text it is supposed to save.

@raysan5 raysan5 merged commit 5076d57 into raysan5:master May 13, 2025
15 checks passed
@raysan5
Copy link
Owner

raysan5 commented May 13, 2025

@JeffM2501 thanks for the review!

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.

2 participants