-
Notifications
You must be signed in to change notification settings - Fork 7.3k
RFC: C11 (or C17) requirement #30105
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
Comments
It seems that logger would benefit greatly from
|
Detecting multi-word arguments should already be handled in cbprintf, but Browsing the C11 additions:
A consideration is that MISRA is not yet past C99. |
Looks precise enough to me. For the versions, I think:
clang
|
The current ESP32 (xtensa) toolchain is:
|
issuing command :
returns :
Development environment:
from reading from devdocs seems GCC v10 supports C17, I can write my app code successfully with C17? |
@tejlmand Thanks for asking. Our toolchain uses clang 9.0.0 as frontend and as such it supports both C11 and C17. We actually set -std=c11 for clang today and have done for a long time. For our custom backend, is a little more difficult to determine whether there will be some corner C11/C17 unsupported areas, but I suspect there will be very few, if any. |
A propósito, somebody should verify or update the recommended toolchain for Vega, which is currently GCC 7.1.1. @MaureenHelm I'm unable to make it work with west with the following commands:
which does work with cmake/ninja directly. |
Latest ARC GNU toolchain is GCC 10.2.0 based (both toolchain from Zephyr SDK 0.12 and standalone prebuilt one) |
Here are version numbers that can be used to determine C standard versions at compile-time with code like:
|
@nashif can you add details on cadence compiler here. |
cadence compiler does not support C11 |
What is the version it does support? |
Could C23, formally ISO/IEC 9899:2024 be considered? |
I discussed this briefly with @nashif. I think that might be a bit too recent to require it at this point. |
We are stuck with GCC 4.1.2. I have a collection of patches to get the features that we need working with it - many of which I have upstreamed. If the C standard is increased it obviously has a bigger impact if this is applied to core constructions such as the device tree, sysinit or device macros versus more peripheral features. |
@jhol For the foreseeable future? We have been extremely cautious when it comes to updating our minimum required C standard version, but this issue is now close to 5 years old, and C11 itself is close to 15 years old. |
I think zephyr just needs to go ahead with whatever is best for the project. I don't see the need to aggressively break support for C99, but I also don't think the project should expend effort trying to support ancient language standards. We are stuck with GCC 4.1.2 because of a tool chain for a vendor architecture port for which we ought to get the source code, but that we won't get. Sadly not atypical inthe embedded space |
The typical solution is: stick to a stable and older Zephyr branch too. Keeping old codebases bug-free and secure is very expensive - but it's less of a maintenance nightmare than trying to piece old stuff and new stuff together. After a while, this will mean bearing the maintenance cost of that stable Zephyr branch yourself. And of course you will get zero new feature. Up to the corresponding vendor whether this is preferable to supporting more recent toolchain(s). C is always touted as "low-level and portable", so how hard could it be to support LLVM? ;-) For sure clang has always been bending over backwards to be as "CLI API" compatible as possible with gcc. |
Thanks @jhol. If you are interested this will be discussed tomorrow in the TSC meeting. |
FYI @RobinKastberg @LoveKarlsson @bjorniuppsala I assume this won't be an issue for IAR? |
I don't think so |
Generics FTW \o/ |
It's worth not forgetting about though. There seems to be quite a number of features in C23 that would be useful.
|
Today MISRA C:2023 and C:2025 also exists with support for C11 and C17/18: https://www.perforce.com/resources/qac/misra-c-cpp |
We internally already require C11 to be used in all of our Zephyr work, mostly for static assertions and anonymous structures, so we'd definitely welcome this change! C23 has a lot of interesting features too but we've not tried it out in a Zephyr project yet. |
Can you elaborate? AFAIK it's already possible to use C11 today without making changes to Zephyr, is it not? This issue is about bumping the minimum version required. |
I think they're just saying that they're having their downstream Zephyr work setup with C11 as a minimum so as to make sure they can leverage the new features, and are happy with it :) |
Apologies, my first comment was not the clearest. |
Definitely. One thing I will do is open a similar RFC for C23 once we've established C11 as the base C standard for Zephyr, so that we can track it closely. Hopefully it won't take nearly as long to switch to it. |
Skip 11, go straight to the fixed up C17, particularly w.r.t. atomics |
100% on atomics |
I think we will definitely need a system to track all of the changes related to the uplift in minimum version. Maybe a new label There are quite a few weird hacks all over the place to account for different language revisions. Do any toolchains or static analysis tools exist to scan an entire codebase and come up with recommended changes? @fabiobaltieri - can AI help here ?? 😅 |
From IAR:
|
Would you mind creating an enhancement issue for those please? |
With the C language evolving, there are a few features in ISO/IEC 9899:2011 (aka C11) that would be useful to Zephyr developers. Given that compiler support for it seems to be already widespread, I'd like to start the conversation to discuss whether switching to it as a requirement to build Zephyr is something we would like to consider.
We could instead require C17, given that it is functionally equivalent to C11 but with some issues addressed.
Please use this issue to describe both features from C11 that you'd like to use and objections or showstoppers that you can foresee if we moved forward with the transition.
The text was updated successfully, but these errors were encountered: