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
Require use of Modern C #339
Comments
|
One interesting aspect is that this recommends using -WError with specific values instead of "any warning". That has very different effects - turning all warnings into errors creates strong dependencies on specific compiler versions, but enumerating a few cases does not do the same thing. This would become something like (for GCC, I suspect clang is similar/identical): -Werror=implicit-function-declaration -Werror=int-conversion
-Werror=incompatible-pointer-types
-std=gnu2x -Werror=old-style-definitionWhen not using autoconf (maybe we can create a workaround by declaring exit() and friends?): -Werror=implicit-intMaybe: -Werror=return-typesThis needs more research. But expressly preventing dangerous constructs that often no longer work, and have been supported (or required) by C99, seems reasonable. 24 years is time enough to fix bad code :-). |
|
I just checked clang 14.0.3; it accepts: -Werror=implicit-function-declaration -Werror=int-conversion
-Werror=incompatible-pointer-types
-std=gnu2x -Werror=old-style-definition
-Werror=implicit-intIt does not accept |
|
I contacted the autoconf developers. Looks like the latest version of autoconf will address some of these. It's planned to be released next week (December 2023). A discussion about this should soon show here: https://lists.gnu.org/archive/html/autoconf/2023-12/threads.html |
This adds some `-Werror` flags to help people switch to Modern C instead of some problematic legacy constructs. Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
This adds some `-Werror` flags to help people switch to Modern C instead of some problematic legacy constructs. Co-authored-by: Thomas Nyman <thomas.nyman@ericsson.com> Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com> Signed-off-by: Thomas Nyman <thomas.nyman@ericsson.com>
This adds some `-Werror` flags to help people switch to Modern C instead of some problematic legacy constructs. Co-authored-by: Thomas Nyman <thomas.nyman@ericsson.com> Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com> Signed-off-by: Thomas Nyman <thomas.nyman@ericsson.com>
It's possible to use flags to enforce use if "modern" C (C89 or later). More info here:
https://fedoraproject.org/wiki/Changes/PortingToModernC
Perhaps those should be added. Some changes may cause autoconf problems, we shoukd document how to address them, e.g., define exit().
The text was updated successfully, but these errors were encountered: