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

lutro: fix a whoooole bunch of prototype warnings. #264

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

jstine35
Copy link
Collaborator

@jstine35 jstine35 commented Jan 22, 2025

An interesting trivia of C99/C11 is that it isn't supposed to allow () for void functions. This is due to a classic rule of C language where () was actually a type of varadic, and matches any number of arguments. Thus, the use of either (void) or (...) is recommended for C programs to clearly differentiate them from the ambiguous () definition. (this doesn't apply to C++ code)

Makefile Outdated
Comment on lines 411 to 412
WARN_FLAGS += -Wno-unused-value
WARN_FLAGS += -Wno-unused-variable
Copy link
Member

Choose a reason for hiding this comment

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

I usually appreciate having these warnings, as it indicates places where issues could arise. Could we go through and fix those issues? Or are they specific to third-party libraries?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed warning suppression. I'll just make a shell script to set WARN_FLAGS env on my end locally.

As for the warnings, they are primarily originating from 3rd party headers. Vorbis is the main offender. A couple of Lua and assertion macros are also sources. The warnings reported between gcc and clang actually differ wildly too, as well as across different versions of clang. It seems very inconsistent which compilers - and which versions of these compilers - judge unused values or variables as worth reporting. This is evidence that compilers are in some cases already trying to reduce the volume of warnings these tend to generate, and have yet to arrive at any consensus on what's good or right.

Copy link
Member

Choose a reason for hiding this comment

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

Since they're third party, it does make things challenging. Is there a way to ignore them just for that code?

An interesting trivia of C99/C11 is that it isn't supposed to allow `()` for void functions. This is due to a classic rule of C language where `()` was actually a type of varadic, and matches any number of arguments. Thus, the use of either `(void)` or `(...)` is recommended for C programs to clearly differentiate them from the ambiguous `()` definition. (this doesn't apply to C++ code)
@jstine35
Copy link
Collaborator Author

Updated description to reflect reduced scope of changes. Warnings behavior is at compiler level is not modified.

@jstine35 jstine35 merged commit ce7de34 into libretro:master Jan 24, 2025
10 checks passed
@jstine35 jstine35 deleted the prototype-warns branch January 25, 2025 01:46
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