On Tue, Aug 23, 2022 at 8:33 PM Alan Rosenthal <alan.rosent...@gmail.com> wrote:
> Hello NuttXers, > > I recently posted an issue to the NuttX Github page: > https://github.com/apache/incubator-nuttx/issues/6896 > > I'll summarize my thoughts here. > > Currently NuttX has a C89 requirement. However, there is code in the > codebase today that is not C89 compliant. Rather than reworking > existing code to be C89, we should reevaluate the C89 requirement. > > C99 and C11 have added a lot of language features, and by updating the C > standard to a newer version, we will add more tools to the NuttX toolbox. Hello Alan, Thanks for sharing your thoughts. I believe one of the big reasons for C89 compliance in the codebase is because NuttX supports a wide range of microcontroller chips, not all of which have a C99 or newer toolchain available. I think that we have been getting away with non-C89 compliance in arch- or board-specific code in places where it is known that the toolchain(s) used with that arch/board do support the newer standard. Yes, there are places in the code where non-C89 code is being used but shouldn't be. I just recently fixed a couple of such cases, such as PR-6853 [1]. We could find violations of C89 automatically by adding the -std=c89 switch when building all shared (non-arch-, non-board-specific files) with GCC (and probably clang). (We might need a few additional command line switches.) Or we could discuss and consider changing the rules. I would be okay with that only if we don't have to abandon users who depend on C89 conformance or give up support for archs/boards that depend on it because of their available toolchains. [1] https://github.com/apache/incubator-nuttx/pull/6853. Cheers, Nathan