ISO updates C Standard (Now we have C11)
h-online.com
h-online.com
- standard multithreading support (<threads.h> header)
- atomic operations (<stdatomic.h> header)
- type-generic macros (sqrt translates to sqrt, sqrtf, sqrtl depending on argument type)
- Unicode support (char16_t and char32_t types)
- gets function is removed from the standard (use gets_s)
- static assertions
- aligned memory allocation (aligned_alloc)
- anonymous structures and unions
- no-return functions (specify functions that never return)
- exclusive access for opened files ("x" in fopen)
- macros to create complex numbers
- additional way to terminate the program (quick_exit and at_quick_exit)http://carolina.mff.cuni.cz/~trmac/blog/2005/the-ugliest-c-f...
Wouldn't this need to be a service provided by the operating system? How can it be part of the standard? Or is it just that the standard prescribes that "x" must work if the operating system allows it.
I know Windows usually defaults to exclusive access, but in practice do any unix-like systems provide exclusive access for file read? Just wondering since I've never requested exclusive read access in my Linux programming.
As to how it can be implemented, "man 2 open" on OSX shows O_EXLOCK and O_SHLOCK flags, and they're from BSD. Not sure if they're POSIX, but I'd bet Linux has something equivalent. And there's also the flock() function. My guess is the new "x" option to fopen can be implemented using O_EXLOCK and flock(), though I'm too tired to look up details on how it could be done.
On some systems, this will mean no locking, on others, advisory locks, on yet others, no locking at all. I bet it will depend on the file system, too (NFS mounts, I am looking at you)
Imagine if da Vinci couldn't stop himself from painting the Mona Lisa and decided to add a little of her endearing facial hair there under the lip.
* C89 + Amendment 1 (and, as usual, try really hard to stay out of the way of the Sasquatch sized footprints being added by the "new and improved standards.")
The differences are primarily that in C you can't use a const symbol in a place where a constant expression is expected (e.g. initializing another const, or a statically sized array).
But you can absolutely do const-correct code in C.
[1]: Preemptive pedanticism: Yes, there are difference between C arrays and pointers, the expression types merely decay in the right contexts. But if I'm using [] to dereference, they're being used as arrays.
At work, we use C90 with a few C99 extensions which can be disabled through the preprocessor (e.g. inline, restrict) and although we stared out with a stdint.h like thing, it is proving to be less useful.
Also, you don't have to use the whole standard. You know there are people who use C++ for hobby projects? That standard is dozens of times larger than the C standard.
Very little, if anything, would have been lost by standardizing "typedef unsigned bool;"
1) It's not about type-checking, it's about reading code.
2) It's not like type-checking is C's strong point.
[This should not be construed as a defense of the rather insane practice of charging for these standards in the first place.]