Enabling VLAs (variable length arrays) in MS Visual C++?
MSVC is not a C99 compiler, and does not support variable length arrays. At https://docs.microsoft.com/en-us/cpp/c-language/ansi-conformance MSVC is documented as conforming to C90.
MSVC is not a C99 compiler, and does not support variable length arrays. At https://docs.microsoft.com/en-us/cpp/c-language/ansi-conformance MSVC is documented as conforming to C90.
See also What are extern variables in C. This is mentioned in the C standard in informative Annex J as a common extension: J.5.11 Multiple external definitions There may be more than one external definition for the identifier of an object, with or without the explicit use of the keyword extern; if the definitions disagree, … Read more
Turns out you can download a MS version of this header from: https://github.com/mattn/gntp-send/blob/master/include/msinttypes/stdint.h A portable one can be found here: http://www.azillionmonkeys.com/qed/pstdint.h Thanks to the Software Ramblings blog. NB: The Public Domain version of the header, mentioned by Michael Burr in a comment, can be find as an archived copy here. An updated version can be … Read more
Passing arrays to functions is a bit funny in C and C++. There are no rvalues of array types, so you’re actually passing a pointer. To address a 2D array (a real one, not array of arrays), you’ll need to pass 2 chunks of data: the pointer to where it starts how wide one row … Read more
The C99 standard does not specify if the three standard streams are unbuffered or line buffered: It is up to the implementation. All UNIX implementations I know have a line buffered stdin. On Linux, stdout in line buffered and stderr unbuffered. As far as I know, POSIX does not impose additional restrictions. POSIX’s fflush page … Read more
It depends on what you mean by ‘truly standards compliant’. However, the short answer is “it is a good idea to ensure that all functions have a prototype in scope before being used”. A more qualified answer notes that if the function accepts variable arguments (notably the printf() family of functions), then a prototype must … Read more
Here is my homework of the day, it’s based on macro tricks and today I particularly learnt about __VA_NARG__ invented by Laurent Deniau. Anyway, the following sample code works up to 8 fields for the sake of clarity. Just extend the code by duplicating if you need more (this is because the preprocessor doesn’t feature … Read more
Actually this excellent answer also answers your question, I think: What does extern inline do? The idea is that “inline” can be used in a header file, and then “extern inline” in a .c file. “extern inline” is just how you instruct the compiler which object file should contain the (externally visible) generated code. [update, … Read more
The behavior of type punning with union changed from C89 to C99. The behavior in C99 is the same as C11. As Wug noted in his answer, type punning is allowed in C99 / C11. An unspecified value that could be a trap is read when the union members are of different size. The footnote … Read more
It is always one in C99, section 6.5.3.4: When applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1. Edit: not part of your question, but for interest from Harbison and Steele’s. C: A Reference Manual, Third Edition, Prentice Hall, 1991 (pre c99) … Read more