C99 boolean data type?

Include <stdbool.h> header #include <stdbool.h> int main(void){ bool b = false; } Macros true and false expand to 1 and 0 respectively. Section 7.16 Boolean type and values < stdbool.h > 1 The header <stdbool.h> defines four macros. 2 The macro bool expands to _Bool. 3 The remaining three macros are suitable for use in … Read more

Visual Studio support for new C / C++ standards?

MS has a series of public replies to this, most of them blaming their users. Like this one: https://devblogs.microsoft.com/cppblog/iso-c-standard-update/ Now, the Visual C++ compiler team receives the occasionally question as to why we haven’t implemented C99. It’s really based on interest from our users. Where we’ve received many requests for certain C99 features, we’ve tried … Read more

Is “inline” without “static” or “extern” ever useful in C99?

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

C99 stdint.h header and MS Visual Studio

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

Can’t understand this way to calculate the square of a number

Obviously a hack… but a way of squaring a number without using the * operator (this was a coding contest requirement). (&a)[n] is equivalent to a pointer to int at location (a + sizeof(a[n])*n) and thus the entire expression is (&a)[n] -a = (a + sizeof(a[n])*n -a) /sizeof(int) = sizeof(a[n])*n / sizeof(int) = sizeof(int) * … Read more

Why does C++11 not support designated initializer lists as C99? [closed]

On July 15 ’17 P0329R4 was accepted into the c++20 standard: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0329r4.pdf This brings limited support for c99’s Designated Initializers. This limitation is described as follows by C.1.7[diff.decl].4, given: struct A { int x, y; }; struct B { struct A a; }; The following Designated Initializations, which are valid in C, are restricted in … Read more

Printf width specifier to maintain precision of floating-point value

I recommend @Jens Gustedt hexadecimal solution: use %a. OP wants “print with maximum precision (or at least to the most significant decimal)”. A simple example would be to print one seventh as in: #include <float.h> int Digs = DECIMAL_DIG; double OneSeventh = 1.0/7.0; printf(“%.*e\n”, Digs, OneSeventh); // 1.428571428571428492127e-01 But let’s dig deeper … Mathematically, the … Read more

What is the difference between C, C99, ANSI C and GNU C?

Everything before standardization is generally called “K&R C”, after the famous book (1st edition and 2nd edition), with Dennis Ritchie, the inventor of the C language, as one of the authors. This was “the C language” from 1972-1989. The first C standard was released 1989 nationally in USA, by their national standard institute ANSI. This … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)