We had a discussion a while back on whether we should move away from
supporting pure C89 compilers. We had made workarounds for some things
in C99 not in C89. Such as we have Ptrdiff_t that emulates that type on
systems where it isn't native, and we have various numeric limits that
are in C99 but not C89.
Since that discussion, I'm finding more things in C99 that would be nice
to have. And I have found some things where we already are in violation
of strict C89, without complaints from the field
A compiler is not required to support infinite numbers of values in an
enum or cases in a switch, or the number of macros you can define. C89
says that a compiler needs to support at least 127, 257, and 1024
respectively. C99 raises those to 1023, 1023, 4095 respectively. Other
limits are similarly increased. (5.2.4.1)
It turns out that we already are in violation of the C89 number of
enums, and my guess, macros too. That means perl is not being used on
systems with these bare minimums. I would like to increase the number
of cases in some switches to beyond the C89 required minimum. This
would make some hot code cleaner, and with fewer conditionals.
C99 also allows you to have a variable length array at the end of a
struct declared as foo[]. (called flexible array members.) C89 works
if it is foo[1], but it makes sizeof harder.
There are other features that C99 offers that would be useful.
My question is can we start using some C99 features beyond what we
already have without running afoul of compilers we work on today?
If so what features are feasible? I am particularly concerned about
using more cases in a switch. Can we relax that C89 constraint?
What C89 things are we stuck with? (I'm guessing we can't assume 754
floating point)?
Can we use other C99 enhancements, like
Flexible array members?
Intermixed declarations and code?
Variadic macros?
// comments?
restrict keyword? (though we could just define this to be nothing if
not already available)
Others?
supporting pure C89 compilers. We had made workarounds for some things
in C99 not in C89. Such as we have Ptrdiff_t that emulates that type on
systems where it isn't native, and we have various numeric limits that
are in C99 but not C89.
Since that discussion, I'm finding more things in C99 that would be nice
to have. And I have found some things where we already are in violation
of strict C89, without complaints from the field
A compiler is not required to support infinite numbers of values in an
enum or cases in a switch, or the number of macros you can define. C89
says that a compiler needs to support at least 127, 257, and 1024
respectively. C99 raises those to 1023, 1023, 4095 respectively. Other
limits are similarly increased. (5.2.4.1)
It turns out that we already are in violation of the C89 number of
enums, and my guess, macros too. That means perl is not being used on
systems with these bare minimums. I would like to increase the number
of cases in some switches to beyond the C89 required minimum. This
would make some hot code cleaner, and with fewer conditionals.
C99 also allows you to have a variable length array at the end of a
struct declared as foo[]. (called flexible array members.) C89 works
if it is foo[1], but it makes sizeof harder.
There are other features that C99 offers that would be useful.
My question is can we start using some C99 features beyond what we
already have without running afoul of compilers we work on today?
If so what features are feasible? I am particularly concerned about
using more cases in a switch. Can we relax that C89 constraint?
What C89 things are we stuck with? (I'm guessing we can't assume 754
floating point)?
Can we use other C99 enhancements, like
Flexible array members?
Intermixed declarations and code?
Variadic macros?
// comments?
restrict keyword? (though we could just define this to be nothing if
not already available)
Others?