ISO Updates C Standard
An anonymous reader writes "The International Organization for Standardization (ISO) has published the new specifications for the C programming language. The standard is known unofficially as C1X and was published officially as ISO/IEC 9899:2011. It provides greater compatibility with the C++ language and adds new features to C (as indicated in the draft)."
Actually, who cares about that?
Seriously, though, am I the only one who finds it strange that one has to buy copies of the standard?
You went AC on this one because you knew it was a horrid thing to say. Are you proud of yourself now? That would measure you.
Help stamp out iliturcy.
Why would Dennis Ritchie have anything against it?
Currently, Microsoft Visual Studio does not even support the C99 standard. Unfortunately, it's unlikely that this standard will be widely adopted any time soon when Microsoft seems to be content to let standard C wither and die.
Microsoft-designed "secure function" cancer?
Many of us gave up waiting on Microsoft for our development tools.
“Common sense is not so common.” — Voltaire
blasphemy +
I'm not willing to pony up 300 swiss Francs, so can anybody tell me, basically, how it is different ? Is it just the stuff that has creeped through in the last few years by means of gcc, or is it totally new ?
Religion is what happens when nature strikes and groupthink goes wrong.
I don't know, but apparently they had to kill him before they could release this ;-)
For those interested, the last draft before the official version is available for free here: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
Microsoft-designed "secure function" cancer?
I'm beginning to think we need a new "law" styled somewhat after Godwin's Law - let's call it "93 Escort Wagon's Law". It goes as follows:
"As any online discussion grows longer, the probability of someone mentioning Microsoft in a derogatory manner approaches 1."
It might also make sense to add a "Slashdot Corollary" under which Microsoft and Apple are interchangeable.
#DeleteChrome
I put C90 (ANSI C) on my resume, because it is more marketable. A serious employer wants to know that I know how to write C90, not just vaguely understand the C language. The fact is if your write ANSI C, it will work with just about any compiler (with the exception of any platform specific code). Many embedded compilers only support a subset of C99 anyway (usually, most, but that's the point, it's not all). ISO fussing with a new C revision is laughable.
The problem is that with C90 you have to write more platform specific code. How do you handle 64-bit integers in C90, for example?
The standard is known unofficially as C1X
GCC already says:
A fourth version of the C standard, known as C11, was published in 2011 as ISO/IEC 9899:2011. GCC has limited incomplete support for parts of this standard, enabled with -std=c11 or -std=iso9899:2011. (While in development, drafts of this standard version were referred to as C1X.)
Syntax is everything in C.
Orwell: "In a Time of Universal Deceit, telling the Truth is a Revolutionary Act"
inb4 Spinal Tap joke
https://www.varnish-cache.org/docs/trunk/phk/thetoolsweworkwith.html
There is nothing in C90 that forbids 64-bit integers. You are thinking about implementations.
Anyone know a torrent for this? $300 is insane. I just want to peruse it.
I think we can generalise it a bit better than that.
"As any online discussion grows longer, the probability of someone mentioning anyone or anything in a derogatory manner approaches 1."
And just those two and no others, because no-one ever says mean things about (let's say) Google or the FSF on this forum. Or maybe a better corollary might be "The better known the person or organization, the faster the probability approaches unity".
Don't let THEM immanentize the Eschaton!
"As any online discussion grows longer, the probability of someone mentioning Microsoft in a derogatory manner approaches 1."
I think we can generalise it a bit better than that.
"As any online discussion grows longer, the probability of someone mentioning anyone or anything in a derogatory manner approaches 1."
It's actually a variant of the typing monkey thing: As any online discussion grows longer (by monkeys typing on their keyboards), the probability of some monkey mentioning *anything* approaches 1.
Don't quote me on this.
In this case it's entirely justified, although those functions have been an optional part of C as TR 24731-1 for a few years. They are entirely pointless (with the possible exception of gets_s) - they only address bugs that result from spectacularly bad code, and the sort of person who writes code that bad won't use the _s variants.
I am TheRaven on Soylent News
C90 does not contain a standard type that has a 64-bit range. C99 defines long long, which must have a range greater than or equal to a 64-bit binary number. It also defines int64_t and uint64_t, which must have exactly the range of a 64-bit binary number. More usefully, it also defines [u]intptr_t, which must have the same size as void*. There is no C90 integer type that is guaranteed to be the same size as a pointer, and the fact that a lot of people assume that sizeof(long) == sizeof(void*) is one of the things most likely to be responsible for code not being portable.
I wouldn't hire anyone who wrote C90 these days. There's simply no excuse for it.
I am TheRaven on Soylent News
OK, so show us a snippet of C90 code that uses 64-bit integers.
There is nothing in C90 that forbids 64-bit integers.
It doesn't forbid them but it doesn't standardise them either. Whether they are provided or not and the mechanism used to provide them is up to the individual implementation and as such any code that relies on them becomes implementation dependent.
note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
Unfortunately when you spend years at light speed en route to and from Alpha Centauri by the time you return due to relativity hundreds or thousands of years have passed on earth. The C standard will be completely obsolete by them. However, the COBOL standard will still be perfectly valid.
No, no, no. This riff only applies to a memoryless process. Long discussion threads are more like star formation. Once you get above a critical mass of Gates, Jobs, Portman, Hitler, Netcraft, emacs, vi, fiat currency, Russian dyslexia, and dcxk intelligent thought can only form at the event horizon, and the fragment emitted is barely visible against the entropic background.
Is that supposed to be a feature?
-jcr
The only title of honor that a tyrant can grant is "Enemy of the State."
You have that exactly backwards. It's C+++ that should die.
-jcr
The only title of honor that a tyrant can grant is "Enemy of the State."
<quote>"As any online discussion grows longer, the probability of someone mentioning Microsoft in a derogatory manner approaches 1."</quote>
As scrutiny grows, the chance of finding Microsoft having done something deserving a derogatory mention also approaches to 1
No, no, it is you that should die.
Bring it on, tough guy.
-jcr
The only title of honor that a tyrant can grant is "Enemy of the State."
Declaring variables at the beginning of their scope
But do you really want to start a new scope every time you declare a variable? Then your code would be filled with so many }}}}}}}}} that it'd look like a curlier version of Lisp.
The whole situation is just the same as what people have complained about Microsoft for: Implementing non-standard stuff
Not necessarily. The GCC project doesn't try to patent language extensions so that others can't implement the extension compatibly, such as using the name "IsNot" for a reference identity operator.
Perhaps. I've never heard of this "C+++" you're talking about, so it's unlikely it added any real value to C++, which itself is one of the finest programming languages ever created.
It may not always be beatiful, but there are so many simply ingenious ideas that it's nothing short of amazing how someone can come up with crap like Java or C# after C++.
Static assertions, so you can do things like _Static_assert(sizeof(int) == 4, "This code path should not be used in ILP64 platforms!"); and get a compile-time error if it is.
There was already a macro for that, involving declaring an array whose size is 1 when true or -1 (and thus invalid in a way that produces a diagnostic) when false.
I will once you show us a snippet of C++ code (in any version of the C++ standard) that uses 64-bit integers. In the real world, code written in C has to interoperate with code written in C++. Did make it into C++11?
I spent my early years programming K&R C on Unix systems.
When the ANSI standards were ratified, ANSI took over.
But WTF is "ISO C"? With a core language whose goal is portability and efficiency, why would I want the language trying to can platform-specific implementations like threading? C is not a general purpose language -- it's power comes from tying to the kernels and platform libraries of the industry at the lowest levels possible to maximize performance.
If you don't need that maximum performance, you use C++ or another high-level language.
ANSI C is the assembler of the modern computing age, not a general purpose programming language.
Now get off my lawn!
the fact that a lot of people assume that sizeof(long) == sizeof(void*) is one of the things most likely to be responsible for code not being portable.
The following is technically not portable, as it's possible for an implementation to choose types that make it fail. But at least it fails fast, using an idiom for a static assertion that works even on pre-C11 compilers:
I wouldn't hire anyone who wrote C90 these days. There's simply no excuse for it.
Other than a major compiler publisher's tools not fully supporting any standard newer than C90, perhaps?
Not sure if you are being sarcastic or not, but you sum up the problem with C++ well. It's exactly because Bjarne has forced any idea he remotely heard about into C++ standard that C++ is a complete incoherent mess of a language it is today.
As the island of our knowledge grows, so does the shore of our ignorance.
Obligatory xkcd.
Real mission critical stuff at Boeing? NASA? All that stuff then right?
Actually their most critical software is probably written in COBOL, their payroll software. Without that COBOL based software nothing gets done. :-)
just asking. I thought everyone nowadays use C#, Visual C++ Microsoft .net, Java, Python, PHP, Ruby, SQL, Assembly. But C? I haven't heard of anyone using C at my university.
#include stdio.h
int main()
{
printf( "Hello World!\n" );
getchar();
return 0;
}
One man's incoherent mess is another man's versatility.
C90 does not contain a standard type that has a 64-bit range. C99 defines long long, which must have a range greater than or equal to a 64-bit binary number. It also defines int64_t and uint64_t, which must have exactly the range of a 64-bit binary number. More usefully, it also defines [u]intptr_t, which must have the same size as void*. There is no C90 integer type that is guaranteed to be the same size as a pointer, and the fact that a lot of people assume that sizeof(long) == sizeof(void*) is one of the things most likely to be responsible for code not being portable.
I wouldn't hire anyone who wrote C90 these days. There's simply no excuse for it.
There is no situation where any of what you just said matters, EVER. If you wrote code in which it does, you shouldn't be allowed to write any code in C ever again, regardless of the standard you've chosen.
I don't care what the size of your pointers are. It really pissed me off to find C code that wouldn't run correctly in 64-bit machines back when AMD first released x64 cpus. You shouldn't be doing pointer arithmetic without fucking checking the size of everything it matters, and you do have access to sizeof, so you shouldn't assume anything.
The one exception is if you're writing highly optimized code that needs to have fantastic performance, but the first thing you're supposed to give up in that situation is portability because you're going to be tuning to that architecture anyway. I've wrote code in which moving to a cpu with less L1 cache would slow everything down considerably because I was counting on a minimum cache size to avoid misses. That thing was not meant to run anywhere else. Situations that need to have code hand optimized this much are rare, getting rarer, and should be avoided if at all possible anyway. So most of the time the C90 stuff is fine, and you just write portable and robust code.
Not that I don't like C99, it has excellent features. However, there's definitely value is writing C90, plenty of embedded systems with compilers that don't understanding anything past that. And if you're writing C, 80% of you are writing for embedded systems.
Why mess with that? If you want more than that, you go with C++. Which isn't too bad as long as you avoid template metaprogramming like the plague...
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
You know, I've always been a fan of pure C, it being so clean, minimal and "the real deal". But I'm getting a bit tired of this fundamentalism and maybe want to extend my skillset. What language(s) would bring on a similarly nice and clean environment, and be worth learning, maybe even get me employed? Python, .NET, etc? Java and C++ feel so bloated... :S
The irony of C++ is that Bjarne explicitly says that the type system was supposed to reduce typecasting, and yet every C++ application I've seen has typecasts all over the place. I rarely, if ever, typecast in C. I've even grepped source trees of comparably sized applications just to confirm my experience.
C++ is an abomination. There will always be idiots writing a ton of crappy code in C and C++. However, at least with C you can spot bad code fairly quickly.
gp said nothing about C, the quote was "Microsoft seems to be content to let standard C wither and die." They release free versions of their compilers, and lots of open source projects provide Visual C solution files as their Windows option.
When lots of code uses non-standard C, and is difficult if not annoying to port, Microsoft has you boxed in. And here's the thing. If you're on Windows, you want Microsoft's IDE and references and everything that comes with it, so Windows users tend to be comfortable with MSVC, personal anecdotes aside.
I remember trying to compile eMule at home, and it required MSVC. I was shocked. An open source app requiring a proprietary tool? Well, when you have the desktop advantage and the primary audience will be computer users, meansing Windows users, why not just go with the OS maker's compiler? And all of its quirks, of course. The compiler is free, it's "native", and it has an effective monopoly for desktop app development. So what Microsoft decides is what you will see in a random code example.
Can someone recommend a good web reference for the new multithreading standard in C1X?
I've never had a problem with just declaring all my variables at the beginning of the procedure. Why do others consider that such a hard thing to do?
"[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz
Unless *all* your functions have less than 10 lines, it leaves variables with a too broad scope, and maybe uninitialized for too long. It also promotes variable reuse when you could create a new one (e.g. reusing the i variable as a loop index, when a narrower declaration would be better).
There is nothing in C90 that forbids 64-bit integers. You are thinking about implementations.
There is also nothing in C90 that requires them, so if you're writing code that needs to run in ILP32 environments but needs to have 64-bit integers, you have to, as peppepz said, "write more platform specific code" - or rely on somebody else (e.g., GLib) to have done so for you (gint64 and guint64 being defined differently for most UN*X C compilers and for MSVC).
so?... Where is it?
I'm a bit confused by your comment. Your anecdote seems to confirm my statement rather than refute it.
“Common sense is not so common.” — Voltaire
When K&R first came out, int's could be either 16 bit or 32 bit and long's were 32 always.
except when longs were 36-bit. And already varied widely because people started running C on things other than a PDP-11.
ANSI C changed this to short is 16, int is 32, and long is "large enough to contain a pointer".
actually that's not true of C89 or C99 (I cannot comment on C1x as I don't want to spend the money on that spec).
int cannot be smaller than an int, but it does not have to be 32. and the only type large enough to contain a pointer is intptr_t.
The rest of your comment is moot as it is based on the premise above.
They release free versions of their compilers
...which don't support C99 (and won't support C11)
If you don't call "letting the standard wither", then I don't know what it is.
(That being said, yeah, you can do most C99-ish things with MSVC by simply adding a "pp" to a few file names. Not that that's always convenient.)
#naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
they would aggressively assist GCC in getting code optimized properly for their chips. AMD has been going the open source route on their drivers. They should help make GCC even better.
Have a look at this presentation ... Scala is very terse and expressive (= good, fun for programmers) and interoperates well with Java (= good for the boss and the business). It is modern, well-designed and has an active community.
"I love my job, but I hate talking to people like you" (Freddie Mercury)
But wouldn't variables declared in the middle of the function still have function scope anyway?
A lack of loop scope is a separate issue.
"[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz
You don't know Bjarne, do you... it's because he does the opposite of what you say that C++ is not three times its size.
Not in the sense you appear to have in mind. This is C, not Javascript or Python. A variable declared halfway through the function has a scope half the size of one declared at the start, and cannot be accidentally read before it has been initialized.
Talk about the pot calling the...oh wait, this isn't the Wikipedia spelling article. Never mind...
If c++ dies, there would be no language that is so compatible with C that it can include its headers and also offer so high level features.
(Ohh dear, yet another narrow-minded USA centric posting — but the, what to expect form /.)
ISO (International Standards Organisation) is for the the other 95% of the human population for whom ANSI (American National Standards Institute) is of no concern.
ANSI was the standards body for C.
Which was only valid standards body for 5% of the human population. That is why all important languages have ISO standards these days.
You mean "enough to encourage high school students to take up programming using non-Microsoft platforms"
Not so fast. Microsoft has announced a plan to require PCs with preinstalled Windows 8 to have UEFI Secure Boot turned on by default, but PC makers aren't required to install any certificate other than Microsoft's or to provide a way for the owner of the PC to install a certificate. This will make it harder for an end user to install a non-Microsoft platform for dual booting without either A. installing Linux into a VirtualBox or B. somehow saving up $700* to replace a desktop PC with a Mac mini. B isn't likely with the child labor laws currently on the books.
* Quoted price includes a Mac mini, a USB DVD recorder, and a display adapter to use the computer with the VGA monitor that a family is likely to already own.