Christopher Collins <[email protected]> wrote on 06-07-2017 17:11:24:

> From: Christopher Collins <[email protected]>
> To: [email protected]
> Date: 06-07-2017 17:12
> Subject: Re: Why not use -std=gnu99?
> 
> 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

Hi, I just wanted to jump in here and suggest that -std=c11 is a better 
choice than -std=gnuXX. If you allow GNU specific extensions then you 
might have issues using other compilers - certainly I would be surprised 
to see the project to rule out clang support in the future. I would 
suggest c11 over c99 as it offers things like atomics which might be 
useful.

The Docker container now uses ARM's latest GCC - 6.1 I think?

Jonathan





This email is from Cambridge Consultants Limited, Science Park, Milton 
Road, Cambridge CB4 0DW with registered number 1036298 England. It may 
contain confidential information. It is intended for the addressee only 
and may not be copied or disclosed to any third party without our 
permission. If you are not the intended recipient please contact the 
sender as soon as possible and delete the material from any computer. If 
this email has been sent as a personal message to the addressee, the 
sender is not acting in his/her capacity as an employee or officer of 
Cambridge Consultants Limited and no liability is accepted for the content 
of any such email. Outgoing email may be monitored for the purpose of 
ensuring compliance with our email policy and relevant laws.


Reply via email to