How to find my current compiler’s standard, like if it is C90, etc

This is compiler dependent, I’m supposing you’re using GCC. You could check your compiler defined macros using: gcc -dM -E – < /dev/null Check the manual about the flags, specially: ###__STDC_VERSION__### This macro expands to the C Standard’s version number, a long integer constant of the form yyyymmL where yyyy and mm are the year … Read more

Why does sizeof(x)++ compile? [duplicate]

The sizeof is an operator, not a function, and as any operator it has a precedence, which is in C lower than of the ++ operator. Therefore the construct sizeof(a)++ is equivalent to sizeof a++ which is in turn equivalent to sizeof (a++). Here we have postincrement on a which is an lvalue so it … Read more

GCC with -std=c99 complains about not knowing struct timespec

Explicitly enabling POSIX features The timespec comes from POSIX, so you have to ‘enable’ POSIX definitions: #if __STDC_VERSION__ >= 199901L #define _XOPEN_SOURCE 600 #else #define _XOPEN_SOURCE 500 #endif /* __STDC_VERSION__ */ #include <time.h> void blah(struct timespec asdf) { } int main() { struct timespec asdf; return 0; } The stanza at the top is what … Read more

How universally is C99 supported?

If you want to write portable C code, then I’d suggest you to write in C89 (old ANSI C standard). This standard is supported by most compilers. The Intel C Compiler has very good C99 support and it produces fast binaries. (Thanks 0x69!) MSVC supports some new features and Microsoft plan to broaden support in … Read more

What’s the C++ equivalent of UINT32_MAX?

Not sure about uint32_t, but for fundamental types (bool, char, signed char, unsigned char, wchar_t, short, unsigned short, int, unsigned int, long, unsigned long, float, double and long double) you can use the numeric_limits templates via #include <limits>. cout << “Minimum value for int: ” << numeric_limits<int>::min() << endl; cout << “Maximum value for int: … Read more

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