Hi Alfred,

On Thu, Jul 06, 2017 at 04:07:17PM +0200, Alfred Schilken wrote:
[...]
> My question:
> 
> Is the mynewt documentation outdated and I should use a newer version of 
> arm-none-eabi-gcc, which maybe has gnu99 (or gnu11) as default?

I believe most of us at Runtime use the same compiler (arm-none-eabi-gcc
4.9.3).  So, in that sense, the documentation is not outdated.  However,
I do think we need to upgrade to a newer version of gcc.  Newer versions
may produce more compact code, and there are bugs in 4.9.3 that have
been fixed (e.g., inability to zero-initialize an object with "{0}").
Newer versions are also better at reporting warnings.

> Or are there any side effects which prevents us using the gnu99-Standard?

I can't think of any negative side-effects.  Some packages already
specify the "-std=c99" flag to allow third-party code to compile.

> If gnu99 is not evil in any kind I would prefer it over gnu89, which is now 
> 28 years old and not even can define a variable in the for-loop.
> After many years of java, python and Swift my C is a bit rusty.
> So I have read Ben Klemens’ book „21 st Century C“ and he describes a lot of 
> advantages in c99, like:
> compound literals for arrays and structs, variable-length macros, designated 
> initializers, definition of variables not only at the top of a function, ...

Just an FYI- I believe gnu89 (not standard c99) already supports all of
those particular features.  Also, just to address a cmomon
misconception: C has always allowed variable declarations mid-function;
they just have to go at the top of a *block*.

> I appended the option -std=gnu99 to compiler.flags.default: in 
> repos/apache-mynewt-core/compiler/arm-none-eabi-m0/compiler.yml 
> and had no obvious negative side-effects with that.
> 
> Maybe this -std=gnu99 should be set in the apache-mynewt-core repo or at 
> least put as a hint in the documentation about "Installing the Cross Tools 
> for ARM“.

I feel like we should just jump to gnu11.  Even that standard is six
years old at this point.

Chris

Reply via email to