Блог пользователя nivin

Автор nivin, 13 лет назад, По-английски

Codeforces normally suggest us to use %I64 for long long. But when I try it in my g++ complier with ubuntu(12.04) I get a warning stated "warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’". Can anyone suggest how do i remove warning and what is %I64?

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

»
13 лет назад, скрыть # |
← Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

normally you should use %lld.

%I64d is VS extension, that currently works in mingw(used on codeforces too), but doesn't work on my g++ on ubuntu.

Codeforces version of mingw didn't support %lld some times ago. But now long long and %lld are in standard(c++11) and it's supported in mingw. So, I don't think it's possible that its support will be stopped. I think you may use %lld on CF now safely.

Small russian discussion.

You may also use this kind of code:

#ifdef ONLINE_JUDGE
#define LL "%I64d"
#else
#define LL "%lld"
#endif
...
long long x;
scanf(LL, &x);
»
13 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +1 Проголосовать: не нравится

You should know that the functions like scanf and printf are actually provided by C runtime libraries. Glibc, which is your case, only supports standard "%lld", while MSVCRT contains non-standard extensions like "%I32d" and "%I64u" in addition. However, MinGW uses MSVCRT60, an ancient version of MSVCRT built before "%lld" became standard. That's why we have to use "%I64d" for and only for MinGW. (Suppose nobody uses VC6 anymore)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

Just say, fuck windows.