You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Alan Rosenthal <al...@gmail.com> on 2022/08/23 18:08:15 UTC

Reevaluate the C89 Requirement

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.

Thanks,

Alan

Re: Reevaluate the C89 Requirement

Posted by Byron Ellacott <bj...@the-wanderers.org>.
Hi,

On Wed, Aug 24, 2022 at 11:58 PM Xiang Xiao <xi...@gmail.com>
wrote:

> On Wed, Aug 24, 2022 at 11:38 AM Nathan Hartman <ha...@gmail.com>
> wrote:
>
> > On Tue, Aug 23, 2022 at 8:33 PM Alan Rosenthal <alan.rosenthal@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.
>

All of the Zilog family CPUs (z8, z16, z80, z180, ez80) use the ZDS-II
development software released by Zilog by default. The C compiler in ZDS-II
is C89 and a C99 requirement will stop the successful build of the z16 and
z80 (z80, z180, ez80 cpu) arches.

Some time ago I contributed the necessary changes for the eZ80 target to
build using an experimental release of clang with Z80 and eZ80 support, but
it's not been sufficient priority for me to either contribute the automated
tests to have it continue to build, nor to even keep reasonably up to date
with NuttX changes, so I can't say for sure that it still builds correctly.
If it does build, then the eZ80 CPU in the z80 arch would at least still be
usable for those willing to use an experimental clang port.

-- 
bje

Re: Reevaluate the C89 Requirement

Posted by Xiang Xiao <xi...@gmail.com>.
On Wed, Aug 24, 2022 at 11:38 AM Nathan Hartman <ha...@gmail.com>
wrote:

> On Tue, Aug 23, 2022 at 8:33 PM Alan Rosenthal <al...@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
>

Re: Reevaluate the C89 Requirement

Posted by Nathan Hartman <ha...@gmail.com>.
On Tue, Aug 23, 2022 at 8:33 PM Alan Rosenthal <al...@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