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

Increase minimum C standard from C89/C90 to C11 #3904

Closed
gruenich opened this issue Feb 11, 2024 · 3 comments
Closed

Increase minimum C standard from C89/C90 to C11 #3904

gruenich opened this issue Feb 11, 2024 · 3 comments
Assignees

Comments

@gruenich
Copy link
Contributor

gruenich commented Feb 11, 2024

Is your feature request related to a problem? Please describe.
C89 (and C90) is a very old language standard which has more recent successors that bring improvements and are wideley supported. Some features from newer standards are missing which makes it sometimes cumbersome to write code. Some strange relics like not allowing variable declaration within a for look (for(int i=0;;) is not allowed), forbidding mixed declarations and code, or having variable declarations without a type (implicit int) are traps to produce bugs.
I could not find a place with a formal definition of the minimal C standard. Using C99 code fails the CI.

Describe the solution you'd like
Increase the minimum C standard to C11.

Describe alternatives you've considered
Stay with C89/C90 indefinitely. This means Zstd cannot profit from C language improvements.

Additional context

  1. The advantages of C11 also convinced the Linux kernel maintainers and they changed for C11 in release 5.18.
  2. Compiler developers treat code with older C standards less strict. This might lead to less warnings or errors that would otherwise revealed potential bugs.
    "Given that C89 code is unlikely to be actively maintained, I think we should be permissive by default in that mode. People compiling with an old -std flag are presumably doing it to keep old code compiling, and it seems appropriate to respect that." (GCC mailing list)
  3. Contributors might be surprised to find out they have to write C89/C90-compatible code.
@gruenich gruenich changed the title Increase minimum C standard from C89 to C11 Increase minimum C standard from C89/C90 to C11 Feb 11, 2024
@Cyan4973
Copy link
Contributor

A compression standard is only useful if one can expect it to be supported by the receiver side. As a consequence, the promise that the Zstandard reference library can be compiled on any platform, and therefore the Zstandard format can be decoded on any platform, is a fairly important one for the health of the ecosystem.
Therefore, we still intend to preserve C90 compatibility of the code base for the foreseeable future.

@Cyan4973 Cyan4973 self-assigned this Feb 11, 2024
@gruenich
Copy link
Contributor Author

Do you have any data that C90 coveres considerably more platforms compared to C11? The Kernel's move went without noticeable fallout. I thought it could be considered for Zstd 1.6, 1.7, or even 2.0.

I understand your position, feel free to close this issue as won't fix.

@Cyan4973
Copy link
Contributor

2.0 possibly,
but not in the foreseeable future.

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

No branches or pull requests

2 participants