Re:Microsoft to C99 Developers: Use ISO C++
by comex on Monday May 07, 2012 @12:36PM
(#3939717)
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, ...
[ Parent
| on HN ]
Self-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.
What do you typically use in C99 that you don't get in C89?
A 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.Some of them are already in MSVC.
Re:Microsoft to C99 Developers: Use ISO C++
by stephencanon on Monday May 07, 2012 @02:36PM
(#3940312)
Off 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>
Re:Microsoft to C99 Developers: Use ISO C++
by onedognight on Monday May 07, 2012 @02:38PM
(#3940323)
I miss C99 named initializers even in C++.
struct { struct y y; bool flag; } = { .flag = true };