jacob navia said:
Please:
The question was
Is this valid in standard C?
And I answer
YES it is valid in standard C!!!!
Correct; officially, the current C standard is the one issued by ISO
in 1999. That standard is not yet as widely implemented as the
earlier standard issued by ISO in 1990, as you should know very well.
And if your compiler is BROKEN and doesn't support standard C
use another one!
That is not always possible, as you should know very well.
The original poster did not mention portability to old broken
stuff, and it did not mention C370, or C90 or C80 or C70!!!
And yes, C89 is not portable to old PDP 11 simulators.
The OP didn't mention PDP 11 simulators, or C370. I don't know what
you mean by C80 or C70.
The C90 standard is supported by almost all current C compilers. I
don't know of a significant platform which has a C compiler but
doesn't have a conforming C90 compiler (ignoring minor bugs, which
exist in virtually all software).
Some systems with pre-ANSI compilers are probably still in use.
Anyone who needs advice about programming in C on such a system can
always ask here. I don't often see such questions these days, but
I'll be glad to do my best to answer them. (My first piece of advice
would be to obtain a conforming C89/C90 compiler if possible; if
that's not possible, there are alternatives I can suggest.)
If you write code that restricts itself to the C90 standard, while
avoiding any incompatible changes in C99 (for example, that avoids
using "inline" and "restrict" as identifiers), that code will be
significantly more portable than code that depends on features that
are in C99 but not in C90.
Of course, such code is valid C99 as well.
This group is always trying to destroy C and to deny
all progress done since more than 10 years of standard
C development.
That is complete and utter nonsense, as you should know very well.
On a personal note, jacob, this kind of deliberate misrepresentation
of other people's statements is probably the most offensive and
annoying thing you do here. Knock it off.
I would be delighted if C99 enjoyed the same level of support as C90.
There are some (but not all) features of C99 that I'd like to be able
to use, and would use without hesitation if they were sufficiently
widely available. But the fact is that I cannot do that.
The differences between gnu c99 implementation and
the standard are absolutely MINOR and only known
to specialists in that matter. To use that to say
the gcc compiler supports some features of c99 only
is a gross misrepresentation of facts.
That's what the gcc project's own web site says, as you should know
very well.
There are features of C99 that gcc does not support. You deliberately
omitted that fact in your response. Why are you trying to hide the
truth, when the gcc project itself explicilty acknowledges it?
If we use the same criteria gcc doesn't compile
C++. It still has a lot to go to implement 100%
of that standard.
I have no idea whether that's true or not; in any case, it's
completely off-topic here, as you should know very well.
I provided information that could be useful to the OP, information
that you deliberately withheld. You deliberately implied that gcc is
a conforming C99 compiler; it clearly is not. It may be close enough
for some particular user's purposes, and if so, that's find. But such
a user needs to have the opportunity to understand what it supports
and what it doesn't, and make that decision for himself.
And even if the latest version of gcc completely and flawlessly
supported the C99 standard, there are plenty of systems that use older
versions of gcc, and a typical user very likely doesn't have the
ability to upgrade the compiler. Furthermore, gcc does not include
the runtime library; rather, programs generated by gcc use whatever
runtime library is provided on the system. In many cases, that
runtime library does not support certain required features of C99.
For example, consider this program:
#include <stdio.h>
#include <math.h>
int main(void)
{
double x = sqrt(2.0);
printf("x = %a\n", x);
return 0;
}
On one system with gcc 3.4.5, it correctly prints:
x = 0x1.6a09e667f3bcdp+0
On another, with gcc 4.0.2, it prints
x = a
because the runtime library (which I'm not able to replace) doesn't
support printf's "%a" format.
But you insist, without qualification, that gcc supports C99, when in
fact it only partially supports it, as you should know very well.
I don't expect to convince you of anything. I've tried and failed
before; I don't expect to succeed this time. I post this as a warning
to others that jacob navia, for whatever reason, apparently wishes to
conceal these facts from programmers who may need to know them.