66 points · by matt_d · 3y ago · 49 comments
[1]: https://en.wikipedia.org/wiki/C23_(C_standard_revision)
The podcast discusses recent and upcoming changes to the C programming language in versions C23 and beyond. It explores new features being adopted from C++, such as auto type inference, attributes, and variably modified types. These changes aim to improve compatibility while staying true to C. The presentation highlights the addition of bit-precise integer types that allow specifying exact bit widths and avoid integer promotions. It also covers new Annex F functions for improved support of IEEE 754 floating point operations. Overall, the podcast examines exciting updates to C that enhance functionality, performance, and security for developers.
- C has seen significant changes over the past 12+ years for the first time, with C23 introducing many new features.
- Some of the new features in C23 are inspired by C++, such as attributes and auto type inference, but aim to stay true to C's spirit.
- Attributes allow providing additional information to the compiler without changing code behavior, and can be standard or vendor-specific.
- Auto type inference makes generic macros easier to write by inferring parameter types.
- Enumerations can now specify their underlying type, like long or unsigned int, for more control over sizes.
- Variably modified types allow array sizes to depend on non-type parameters without stack allocation issues.
- New integer types like intN_t specify exact bit widths and avoid integer promotions.
- New macros help with endianness and bit manipulation operations in a portable way.
- Annex F for floating point is now in parity with IEEE 754-2008 for more consistent floating point behavior.
- Memory clearing functions like memset_s were added to improve security by overwriting secrets before freeing memory
also
[no way to adjust playback speed].
TL;DW auto, constexpr from C++ and I made a mental note to find a better source.
Auto and constexpr fix specific problems that also exist in C (auto is useful in type-agnostic macros, and constexpr finally fixes the problem that a const isn't actually a constant.
One interesting tidbit (which I didn't know yet) is that the C committee requires two real-world implementations for a proposal to even be considered (with the C++ standard counting as "implementation"), while the C++ committee doesn't require an implementation. Meaning C++ users are essentially guinea pigs for the C standard ;)
Explains why C++ has become such a hot mess, while C has been mostly spared any serious f*ckups (I can only think of one: VLAs, but those have essentially been removed from the standard in C11).
I've seen K&R C a few times, even in modern (well, "modern") code, but I don't think I've ever encountered trigraphs. The proposal mentions that "instances of trigraphs being deliberately used in production code" via a codesearch.com query, but that's public code only (and probably only recent, and incomplete?)
[1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2940.pdf
https://searchcode.com/file/12650181/blib/lib/prawda/grammar...
Doesn't turn into anything meaningful with trigraph replacement. I'd guess that it's essentially a giant regex matching a header in some horrible, unknown dialect, but I'm not brave enough to look through the codebase to find out.
They’re disabled for gnuXX values of the -std= flag, but enabled for cXX. And for the latter you can’t disable them by any finer-grained flag.
Here’s some real code which starts with trigraphs. Note it only uses the trigraph for the initial pragma to establish the EBCDIC code pages, later on it doesn’t use them. (Also, that file contains some invalid characters because it was converted from EBCDIC to ASCII using the wrong code page.)
https://github.com/mainframed/CBTTAPE/blob/main/CBT880/CBT.V...
This is a tool for storing dumps (basically mainframe equivalent of core dumps) on a networked Unix filesystem. Someone wrote it because they didn’t have enough space on their mainframe to store the dumps, but did on networked Unix storage. And then they released the source code (not clear what license)
https://raw.githubusercontent.com/mainframed/CBTTAPE/main/CB...
Never actually used it (I’ve never had cause to use mainframes professionally, I just like studying them in my spare time)
[0] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n29...
No I've never seen them anywhere .
Not in our lifetime I know, but we sort of understand why we have year 2000 problem. It seems as human, we know what that missing years are or “reverse numbering” is ok.
But I’m glad to see 0x66’53’ef’03 and printf(“%b”,x); and bsearch and all the bit functions.
Or just don't use NUL-terminated strings, seriously: zero-terminated arrays are very uncommon except when it comes to char arrays in which case they're everywhere.