4 ms·
If MSVC supported C99, it would be portable enough for the three major platforms plus all the ports of GCC and any analyzers written for Clang/LLVM. What do yo
by comex 15y ago
If MSVC supported C99, it would be portable enough for the three major platforms plus all the ports of GCC and any analyzers written for Clang/LLVM. What do you get versus C++? Implicit casting of void *, so you don't have to repeat yourself every time you use malloc, restrict, structure literals, faster compilation (yes, the same code compiles faster in C mode than C++ mode, at least in gcc), not having to remember slightly different rules about scoping, ...
- comex 15y agoSelf-reply: That's only C99, by the way. Compared to C++11, C11 adds anonymous structs, and incompatible handling of atomics, noreturn, and even generics.
- dsrguru 15y agoWhat do you typically use in C99 that you don't get in C89?
- oconnore 15y ago'for' loops
- _delirium 15y agoA few things I like, though not all of them are strictly needed: long long foo; /* bigger ints on 32-bit platforms */ uint32_t bar; /* stdint.h, integers of specific bit width */ int array[n]; /* length-n array, where n is a variable */ for (int i = 0; i < n; i++) /* loop-local variable */ Also, the safer stdio functions like snprintf.
- yuhong 15y agoSome of them are already in MSVC.
- stephencanon 15y agoOff the top of my head, C99 features that I've used in the past couple months: - declarations mixed with statements - declarations in `for` constructs - hexadecimal floating-point literals and conversion specifiers - the strtoxx( ) conversion routines - the restrict qualifier - the expanded math library - designated initializers - extended integer types - compound literals - // comments - VLAs - complex support Note that some of these features are still not present in C++11. C11 features that I have used in the past few months: - CMPLX macros - anonymous structures and unions - <stdalign.h>
- onedognight 15y agoI miss C99 named initializers even in C++. struct { struct y y; bool flag; } = { .flag = true };