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.
Many of us gave up waiting on Microsoft for our development tools.
“Common sense is not so common.” — Voltaire
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"
https://www.varnish-cache.org/docs/trunk/phk/thetoolsweworkwith.html
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
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
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.
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."
Actually, Alpha Centaru is only ~4.4 ly away. If you travel there and back at near-lightspeed, your friends on Earth will only have noticed you were gone for ~8.8 years, and thanks to time dilation, practically NO time will have passed for you.
It is, because it helps write libraries in C which remain usable from C++.
<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
If C++ code can't call C code, that's a bug for C++ people to fix. All the competently designed languages deal with C just fine.
-jcr
The only title of honor that a tyrant can grant is "Enemy of the State."
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 free sample in alpha centauri is in a filing cabinet in a dark basement guarded by leopards.
Your time dilation assumes c towards Alpha Centauri, instant deceleration to 0, collect pdf and instant acceleration to c towards earth. Wont work.
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
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.
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. :-)
No, no, no. That's not the issue. C++ can automatically call any C code using 'extern "C"'. The issue is, how will C++ do *COMPILING* C source in C++ mode. C++ is not a true superset of C, so C is not a true subset of C++. Anything that makes them closer to being a super/sub set pair is a Good Thing.
It's OK. C++ is the MOST able to call C of any language. Parent was confused.
One man's incoherent mess is another man's versatility.
Your time dilation assumes c towards Alpha Centauri, instant deceleration to 0, collect pdf and instant acceleration to c towards earth. Wont work.
Yes. THAT'S the problem with heading to Alpha Centauri. First of all, if we're imagining an interstellar ship capable of lightspeed travel, why not give it one of these? Second, fine--my starship accelerates at 1 gee (spaceship frame) for half the trip, then decelerates at 1 gee for the other half. To me, the trip takes two years each way. To my friends on Earth, I'm gone for about 10-20 years, if I remember this calculation correctly. Still I can get there and back in far less than fifty. The Vogons were *completely* reasonable.
As for the leopards in the basement cabinet... well.
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
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.
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
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
http://spectrum.ieee.org/at-work/tech-careers/the-top-10-programming-languages
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).
Your time dilation assumes c towards Alpha Centauri, instant deceleration to 0, collect pdf and instant acceleration to c towards earth. Wont work.
Is that c 9x or c 1x? Must be 9x else you wouldn't be going to Alpha Centauri to get the new c spec.
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
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; }
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)
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.
I'm familiar with octal based arch's such as Sperry/Univac/Honeywell/whatever. The ones that had the oddball sizes died a slow painful death. The ones that survived and prospered were the ones that had word sizes that were 8/16/32/64. Devise a 36 bit arch these days and it will go nowhere. As to what most people used after a PDP/11, it was [no surprise] a Vax.
My first C compiler was on a PDP/11 (Unix V7) and it got ported to 8086's and some m68k's (int's were 16 bit). But, some m68k's got their port from the Vax compiler, where int's were 32 bit. On the m68k's, the 32 bit compilers were a lot easier to deal with.
If a short isn't 16 bits (which it has been on any compiler I've ever seen), what would the compiler intrinsic type be? Not some crufty int*_t typedef, but what the crufty typedef would typedef to (e.g. typedef short int16_t equivalent?)
And speaking of crufty typedef's, before cstdint* there were caddr_t, ptrdiff_t, and uchar/byte, s16/u16, s32/u32, s64/u64. To my mind, no less clear and shorter (which is a benefit). For high usage types (e.g. int), everybody knows what you mean (e.g. you don't have to spell out "integer" as in Fortran/PL1)
As a practical matter, forget the spec. On this point, it's just as inane as IETF specs that still insist on using "octet" instead of byte. The reason they did that was because of Sperry(?) et. al. which didn't have an 8 bit byte size. If you wish to disagree with that, when was the last time you told somebody you were downloading a 50 megaoctet file?
If somebody wants to name the compiler and architecture that doesn't have int as 32 (that are still in use--as the 36 bit model had vacuum tubes and core memory, circa 1960 era, with some stragglers), I'd like to know about it as it would break 99.44% of existing C code. If a modern compiler/arch needs a 36 bit intrinsic type, it will not co-opt a current [well understood] type, it will create something like "__builtin_int36_t" and leave int alone. That's what intel does for its SIMD/Larabee extensions
As to the floating 32/64 bit size of "long", it appears to be supported on gcc/clang/icc(?). AFAIK, the only 32/64 bit switchable compiler that chooses not to honor this is VC. So, what's the rationale for long's floating nature in these compilers, if the "long contains pointer" isn't true?
Like a good neighbor, fsck is there
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
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.
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.
If a short isn't 16 bits (which it has been on any compiler I've ever seen), what would the compiler intrinsic type be? Not some crufty int*_t typedef, but what the crufty typedef would typedef to (e.g. typedef short int16_t equivalent?)
Whatever the compiler writer decides to make it. No guarantee it's a type defined by C89 - or C99 (the spec just says the int N _t types are "signed integer types", not "standard signed integer types", so they could be "extended signed integer types").
As a practical matter, forget the spec. On this point, it's just as inane as IETF specs that still insist on using "octet" instead of byte. The reason they did that was because of Sperry(?) et. al. which didn't have an 8 bit byte size.
Sperry and Digital Equipment Corporation (PDP-10) and General Electric^W^WHoneywell (GE 645/Honeywell 6180).
If somebody wants to name the compiler and architecture that doesn't have int as 32 (that are still in use--as the 36 bit model had vacuum tubes and core memory, circa 1960 era, with some stragglers), I'd like to know about it
Presumably "vacuum tubes" is hyperbole, given that even the PDP-6 was transistorized. The only 36-bit architecture for which there are significant surviving implementations that I know of is the Univac 1100-and-descendants architecture, and Unisys does appear to claim to support C.
(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 can. The point in question is not ABI compatibility - it is there with extern "C". The point is to be able to directly use C header files without having to rewrite all declarations, as you have to do with most other languages (or use some tools that try to do it for you). Most C header files today are wrapped in #ifdef __cpluspus / extern "C" for just this reason. For the same reason, it makes sense to define new language facilities in a more or less compatible way, such as the newly added ability for explicit data alignment.
You mean like this?
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.