I've spent two decades writing C and C++, but the last 8-9 years in really high-level languages (Ruby, Javascript, Python). From either end of the spectrum, I've never felt the need for such emphasis on fixed-sized numeric types.<p>I've commonly needed <i>access to</i> fixed size numerics, like when sending texture formats to the GPU, defining struct layout in file formats and network protocols, but I have never once thought: "You know what, I'd like to make a decision as to the width of an integer every time I declare a function."<p>"Just has to work" low level code was the norm during the 16-bit to 32-bit transition, so it was a fucking pain. Notice how smooth the 32-bit to 64-bit transition went? (and yes, it was smooth.) I credit that to high-level languages that don't care about this stuff, and people using better practices like generic word-sized ints and size_t's in lower level code. Keep that stuff on the borders of the application.<p>I've noticed a decent-sized emphasis on type size in both Crystal and Swift, two not-entirely braindead newer languages. I don't get it, it's a big step backward.
You can write C in any language. You can also write any language in C.<p>The fact that it's possible does not imply that it's a good idea. Some of the macros here are in common use (e.g., countof, although often with other names); some will make experienced C developers say "what's this? Oh, you mean <insert expansion here>; why did you use a weird macro?"; and some, like the redefinitions of <i>case</i> and <i>default</i> are actively hostile and are guaranteed to result in bugs when exposed to experienced C developers.<p>For more of the same, see "things to commit just before leaving your job": <a href="https://gist.github.com/aras-p/6224951" rel="nofollow">https://gist.github.com/aras-p/6224951</a>
I'm not sure that 'address' is desirable.<p><pre><code> int adress adress adress foo;</code></pre>
vs<p><pre><code> int * * * foo;
</code></pre>
Double pointers are extremely common and triple pointers show up now and then.<p>Also '__attribute__ cleanup' as far as I know only works with automatic variables that live on the stack. Mucking about with code execution and automatic variables as the stack unwinds is not a style I would like to see in general purpose C coding. Its the one type of automatic memory management that you get for free and can't really screw up.<p>The rest of the macro loops and so forth seem fairly standard. Its good to experiment and explore what you can do with the compiler and the preprocessor.
Very cool! I wasn't aware of the cleanup attribute, can't wait to try it out:<p><i>The cleanup attribute runs a function when the variable goes out of scope. This attribute can only be applied to auto function scope variables; it may not be applied to parameters or variables with static storage duration. The function must take one parameter, a pointer to a type compatible with the variable. The return value of the function (if any) is ignored.</i><p><a href="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html" rel="nofollow">https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attribute...</a>
Maybe the author wanted this to be C99 compliant but a cool thing is that by using clang we even have lambdas. It's called blocks, the same as in Objective-C.
<a href="http://clang.llvm.org/docs/BlockLanguageSpec.html" rel="nofollow">http://clang.llvm.org/docs/BlockLanguageSpec.html</a><p>I've been using them in all my new C code, since I'm stuck to clang anyway, and it's awesome.
this is basically an updated version of iso646.h<p>[<a href="https://en.wikipedia.org/wiki/C_alternative_tokens" rel="nofollow">https://en.wikipedia.org/wiki/C_alternative_tokens</a>]<p>...and no, they're not a good idea, its just a syntactic change.
If you want a 'better-C', language-wise, Rust is pretty much best current hope, tho that wont mature for another decade or so.
That is very impressive. I really like the cleverness and cleanliness of these "hacks".<p>Still... I wouldn't introduce it into existing/shared codebase due to risk of confusing everyone, and I will never start my own project in C again.
I wonder if this is in any way inspired by this - <a href="https://github.com/google/honggfuzz/blob/master/common.h" rel="nofollow">https://github.com/google/honggfuzz/blob/master/common.h</a> ?<p>I use there defer for both gcc/clang, countof(arr) -> ARRAYSIZE(array)<p>In any case, yeah, going through gcc/clang internals, and through C11 standards gives people some ways to speed-up and clena-up their implementations a bit.