What is C99? Who needs it? Is it available yet? The author discusses the 1999 revision of the ISO C standard, with a focus on the availability of new features on Linux and BSD systems.
Open source development using C99
About The Author
Eugenia Loli
Ex-programmer, ex-editor in chief at OSNews.com, now a visual artist/filmmaker.
Follow me on Twitter @EugeniaLoli
21 Comments
“Closed source software is not any better: if the authors don’t want to implement your request, then you’re *completely* out of options. ”
Don’t buy. If the compiler doesn’t comply to the standard, then why the hell would you buy it in the first place? The whole point of the standard is to enforce consistency and is supposed to be viewed by all implementors as the MINIMUM contract of implementation.
Unfortunately, an extraordinarily prolific and unquestionably broken implementation coupled with an apathetic development team add up to a weakened standard.
Because the standard is so weak, it makes industry less likely to consider a major burden to implement the standard.
C has never been a consistent platform and implementations have been all over the map. However, GCC has lowered the bar.
If GCC actually stuck to the standards, then I’m quite convinced that commercial implementations would quickly realize that they needed to catch up to make money. With things such as they are, why break your back cleaning up the corner cases when the de facto implementors don’t give a shit?
Its not nearly as bad as you put it. I don’t know how uncompliant gcc is with C99, but its *very* compliant with the C++ standard. Indeed, one of the prime reasons a lot of the new template metaprogramming stuff was able to be widely used is that there was a good implementation of it available in GCC. The biggest commercial compiler vendor on the PC, Microsoft, lagged very significantly behind GCC with regard to C++ standards compliance for a number of years. It is only their latest C++ compiler (VS.NET 2003) that can match gcc’s C++ support.
export is still the best answer to the problem you have with template definitions.
And funny you should mention EDG. They were the ones most adamantly against ‘export’ in the standards committee. But once it was decided that ‘export’ is part of the standard, they sat down and implemented it, instead of ignoring the issue.
That is the spirit. (And the basis of democracy, by the way. You may oppose an idea, but once the vote is taken, it’s your damn duty to help implementing it.)
Yes, implementing ‘export’ is a major pain, and maybe it doesn’t solve all the issues in the most brilliant way. But it’s in the standard, and it’s in there because it solves a problem with templates. Saying “it’s bad, it’s trouble, so we don’t care whether it’s part of the standard” is simply not the way to go. Not for Microsoft VC++, and not for GCC.
There is one problem using C99 for open source or free software – there is AFAIK but one compiler supporting it; GCC.
Yes, GCC is widely available. So? What if I’d want to use another compiler? Say a Microsoft compiler (since Microsoft have publicly stated they will not support C99), or I want to (try to) port the code to C++ – C++, which is based on C89.
While the fetaures added were all probably good, they have also created two completely different languages. C99 is not C89, and can vever be made to compile with a C89 compiler (and therefore not a C++ compiler).
I have already been bitten by this, and I don’t think it’s one bit of fun…
That’s why there is gcc -c99 and gcc -c89 and g++…
> What if I’d want to use another compiler?
If you want to use another compiler, you’re usually out of luck anyways because only very few library headers have ever been tested against another compiler (or the standard, C99 or C89). The GNU / OSS standpoint on this seems to be, if it works with gcc, it’s “correct” enough. :-
There is no point in implementing a feature that people (including C++ luminaries) think shouldn’t have been in the standard in the first place. That’s precisely the case with ‘export’, and one of the reasons even Microsoft, who has otherwise pushed forward with their efforts to adhere to standardized C++, has yet to touch ‘export’.
“Its not nearly as bad as you put it. I don’t know how uncompliant gcc is with C99, but its *very* compliant with the C++ standard.”
I view compliance with a standard as a binary thing: an implementation either complies with the whole specification, or it doesn’t. Are you trying to say that it is *very close to* complying?
I really question gcc’s enthusiasm for supporting standards when I read their own documentation what features are broken, unworkable, and also unlikely to be fixed soon. When an entire community of developers becomes dependent on a long-broken ABI (gcc before 3.0), and attempts to correct the flaws (some, not all, of course) are met with yelps and gnashing of teeth, it really weakens my confidence in the whole GNU toolchain.
Go read the developer’s submit conference proceedings, or scan the mailing lists that have nightly regression tests running…when you see how many tests fail, consistently fail, are expected to fail, and unexpectedly fail, you might be surprised. C++ happens to be consistently the worst as far as regression test failures, too. The best? Objective C. Who supports the Objective C frontend? Apple.
Funny that you should mention this:
> There is no point in implementing a feature that people
> (including C++ luminaries) think shouldn’t have been in
> the standard in the first place.
At this very moment, at the next desk from mine, is a codeveloper of mine who happens to be on the C++ committee. He agrees that ‘export’ is a bitch to implement and doesn’t solve all the problems with templates.
But he, too, is still waiting for ‘export’ to appear in gcc, because he would *really* like to make his code more maintainable…
So, before you claim that no-one wants ‘export’, ask those who actually know how to write template code, and actually feel the lack…
–pendantic not being correct in all places, integer promotion being slightly off, inline having different semantics… that’s only what this paper mentions.
I feel it’s lamentable that gcc supports the fine print of standards so badly. Better than many lesser products, mind you. But too many things go by “no-one needs it anyway”, “fix it yourself if you want it” and “our GNU-specific solution is good enough for us”. Lamentable, especially for the OSS community being so hot on complying with open standards for the greater good of computing. You would expect that gcc’d be the most compliant compiler around… (and I’m still waiting for export in g++…)
And how’s “fix it yourself if you want it” not a good answer? They are volunteers, you didn’t pay them, so it’s completely unreasonable to expect them to do everything you want.
If you really want something badly and you can’t do it yourself, you still have choices:
1. Hire a programmer to do it for you.
2. Contact your (commercial) distributor.
Closed source software is not any better: if the authors don’t want to implement your request, then you’re *completely* out of options.
If closed source authors do listen to you and implement something because you paid them… well that’s no different than hiring a professional programmer to work on a piece of open source software!
In other words: you can’t expect people to do everything for you for free; that’s just arrogant. It’s not an “open source problem”, it’s a money problem.
If you still want something then show your wallet.
A typical Anonymous…
> And how’s “fix it yourself if you want it” not
> a good answer?
Because I want to spend my time on my own project, not on improving the compiler?
> you didn’t pay them, so it’s completely unreasonable
> to expect them to do everything you want.
Erm, sorry.
1) It wasn’t me who decided to give GCC away for free, it was the GCC people. If they now feel the pain implied in their decision, too bad. I am not morally obliged to pay them.
2) Compliance with a language standard five years old isn’t some custom request, but a basic requirement. Not meeting the requirement is a bug, not a missing feature, and I don’t pay a commercial vendor for bug fixes, either.
That’s when the big words – “OSS is better because bugs are fixed faster” – meet the reality – “only if the people working on it are actually interested enough”.
I don’t want to belittle GCC. It’s a damn fine compiler, and kudos to the developers for releasing it free of charge. But that must not excuse failure to comply with the language standard.
All I wish for is a visible effort in fixing this ASAP, but last time I looked, standards compliance ranked somewhere mid-field because “it works fine for us as it is”, and “you can fix it yourself”. Bah.
For C99 using TenDRA:
tcc -Yc99 -Ysystem
I am not sure how complete–it works for me –it is, but standards are high priority there (http://www.ten15.org).
here you go:
http://www.freshports.org/lang/TenDRA/
“I am not morally obliged to pay them.”
Then they are not morally obligated to help you. Just like closed source developers aren’t morally obligated to help you if you don’t pay them.
“That’s when the big words – “OSS is better because bugs are fixed faster” – meet the reality – “only if the people working on it are actually interested enough”.”
Unless you pay them. Guess what – the same applies to closed source too!
“Not meeting the requirement is a bug, not a missing feature, and I don’t pay a commercial vendor for bug fixes, either.”
You don’t pay Microsoft for getting the latest version of Visual C++ with improved standards compliance?
They get paid, just like a lot of OSS programmers get paid. Companies like amd or ibm pay programmers to code for gcc, just like suse pays their programmers to code for kde for example.
That’s funny because if you read Slashdot, almost everybody says you can’t make money from OSS sofware and even get modded up.
Whether I pay for it or not, whether I can fix it myself or not, whether it’s OSS or not is besides the point.
C99 is an international standard for the C programming language. The GCC compiler suite supports a command line switch, and provides the preprocessing symbol claiming that it’s C99 compliant, but it is broken. Just like many other compilers, but it’s still buggy.
And up steps Mr. Anonymous (why do those types never care to give even so much as a nickname?) and tells us that’s OK and we’re in no position to complain because, hey, it’s “free”.
It’s the very attitude that’s hurting OSS so much (as recently discussed in another thread here). You should take pride in your software, strive to make it as bug-free and reliable as possible. Walk the walk, not just talk the talk.
Again. The most important C/C++ compiler of the open source software community does not fully support the language standards. That’s very bad advertising, “free” or not. No, especially for “free” software, because it shows that, once the brunt of the work has been done, such nickling details like full standards compliance, good manuals etc. get left behind. “Works for me, fix it yourself.” Yeah.
I think a lot of efforts in the GCC team has been focused on making the compiler compliant to the C++ standard (which they have achieved about as well as any of the commercial companies), so its not surprising that C support is a bit behind. And don’t hold your breath for ‘export’. Its not gonna happen anytime soon. ‘Export’ is DOA — the only front-end that properly supports it is the EDG one, and the only compiler I know that supports it is Comeau C++.
If you *really* need export, go ahead and buy Comeau. Its only $50, and its a good compiler.
To clarify my last statement: Export is so widely unsupported because its widely regarded to be a misfeature. It has some glaring limitations, and is usually not successful in doing the things it attempts to do.
Is another interesting open source compilar.
http://www.openwatcom.com/
I’ve never used it, and am not sure how standards compliant it is, but it may be worth checking.
here you go: