Forcing C99 in CMake (to use ‘for’ loop initial declaration)

After creating a target such as a library or executable, put a line like this in your CMakeLists.txt file: set_property(TARGET tgt PROPERTY C_STANDARD 99) where tgt is the name of your target. I think this was added in CMake 3.1, and the documentation is here: http://www.cmake.org/cmake/help/latest/prop_tgt/C_STANDARD.html If you need to support versions of CMake older … Read more

C program yielding different results on different machines despite using the same fixed length data types

It seems you might get this problem in case you are using a Windows compiler which uses Microsoft’s non-compliant CRT (non)standard library. That is: Visual Studio or Mingw64/gcc. I can reproduce it on Mingw/gcc. It’s a well-known problem that the Microsoft CRT is broken and for example doesn’t support various format specifiers introduced in C99. … Read more

tech