On Wed, Aug 24, 2022 at 11:38 AM Nathan Hartman <hartman.nat...@gmail.com>
wrote:

> 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.
>
>
Here is the arch supported by NuttX:
C99
arm Y
arm64 Y
avr Y
ceva Y
hc
mips Y
misoc
or1k Y
renesas Y
risc-v Y
sim Y
sparc Y
x86 Y
x86_64 Y
xtensa Y
z16
z80
I don't know which compiler is used for hc, misoc, z16 and z80, but other
arches support C99 very well.
So, the question is whether the C99 requirement will impact these four
arches.

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.)
>
>
But we found that some C99 features(e.g. inline) are very important to
generate efficient code in the recent optimization work. So it's better to
relax the rule to exclude some well supported C99 features.


> 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
>

Reply via email to