[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [task #7054] Clarification needed for variable initializati
From: |
David Empson |
Subject: |
[lwip-devel] [task #7054] Clarification needed for variable initialization |
Date: |
Thu, 05 Jul 2007 23:57:36 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 |
Follow-up Comment #13, task #7054 (project lwip):
ISO/IEC C99 support is patchy at present. None of the embedded compilers I
use are anywhere near being compliant with it.
I think it is reasonable to expect a high degree of ANSI/ISO C90 compliance,
and LWIP should not be bending over backwards to cope with compilers that
aren't ANSI compatible at all.
LWIP should be avoiding features which require C99 or extensions to the C90
standard (such as // comments).
In my opinion, a compiler which doesn't set static variables to zero on
startup is seriously broken, as it doesn't comply with any C standard.
GCC is reasonably compliant with C90 (plus extensions) and implements several
features of C99, so I wouldn't call it "broken".
My concern with the INIT_NULL solution is not its effect on the object code,
but on the readability of the source code. Several variables using INIT_NULL
in one area of a source file will look ugly.
If this proposal is carried through, I'd also suggest INIT_ZERO as a better
name, since INIT_NULL implies a pointer. Perhaps both should be used:
INIT_ZERO for arithmetic variables, INIT_NULL for pointer variables. This
also allows for compilers which define NULL as something "better" than (void
*)0.
Arrays could use INIT_ARRAY_ZERO, but structures and unions need the same
macro, so a more generic name would be better. INIT_AGGREGATE_ZERO is the
best choice but is too long.
I'm interested to note that the C90 standard allows a scalar to be
initialized with a brace-enclosed expression, e.g.
int a = {0};
I've never tried this and some compilers might not like it. If it is
supported by all compilers, then INIT_ZERO can be declared as
#define INIT_ZERO = {0}
(or blank if not required) and this will work with variables of all types.
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/task/?7054>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
- [lwip-devel] [task #7054] Clarification needed for variable initialization, (continued)
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Frédéric Bernon, 2007/07/04
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Frédéric Bernon, 2007/07/04
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Frédéric Bernon, 2007/07/04
- RE: [lwip-devel] [task #7054] Clarification needed for variable initialization, Goldschmidt Simon, 2007/07/04
- [lwip-devel] [task #7054] Clarification needed for variable initialization, David Empson, 2007/07/04
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Simon Goldschmidt, 2007/07/05
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Frédéric Bernon, 2007/07/05
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Frédéric Bernon, 2007/07/05
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Simon Goldschmidt, 2007/07/05
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Frédéric Bernon, 2007/07/05
- [lwip-devel] [task #7054] Clarification needed for variable initialization,
David Empson <=
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Kieran Mansley, 2007/07/13
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Jonathan Larmour, 2007/07/30
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Frédéric Bernon, 2007/07/30
- [lwip-devel] [task #7054] Clarification needed for variable initialization, Jonathan Larmour, 2007/07/30
- RE: [lwip-devel] [task #7054] Clarification needed for variableinitialization, Bill Florac, 2007/07/30