long long on Windows/Dev-C++/MinGW

[sarcasm on]
(because Moldova is probably the last country where programming competitions are still held on Windows)
[sarcasm off]

The long long data type has been introduced in C as part of the C99 standard. On 32-bit machines it is a 64-bit signed integer data type. The printf/scanf formatting string for this type is %lld.

Using Dev-C++ and the MinGW port of the GNU C Compiler on Windows, one would expect programs to run the same way they do with GCC on Linux. But no! Apparently MinGW calls the Windows libraries, so every time you call printf or scanf you’ll end up using Microsoft’s version of the functions!

And of course Microsoft cares about backwards compatibility, so when C99 was published they didn’t switch to the standard, keeping their non-standard %I64d formatting string instead!

[subsides into an angry stream of unintelligible muttering]

3 Responses to long long on Windows/Dev-C++/MinGW

  1. gr8dude says:

    I also stumbled upon it; that’s when I told myself that when on Windows, MSDN should be the #1 source of information.

  2. Phil says:

    Damn! Thanks a lot for that information, although it really sucks because it makes me having a hard time to keep my applications totally C-Standard-Library portable. Anyways, fuck Microsoft.

  3. […] Exista tipul de date long long care este reprezentat pe 8 bytes care ia valori intre -262+1 pana la 262-1. In BorlandC acest tip de date nu exista. Pentru a citi/afisa numere pe 64 de biti cu libraria <stdio.h> se foloseste specificatorul de format non-standard “%I64d”. Cateva detalii aici. […]

%d bloggers like this: