int64_t == long long

Yang Zhang yanghatespam@gmail.com
Tue Jul 1 19:18:00 GMT 2008


Hi, why isn't int64_t == long long at least on 64-bit x86 Linux?

http://gcc.gnu.org/onlinedocs/gcc-3.3.6/gcc/Long-Long.html

says that these are *at least* 64 bits.  How do I tell what type this 
actually is?  And are literals ending with LL always long long?

Thanks in advance for any answers!



$ uname -a
Linux yang-xps410 2.6.24-19-generic #1 SMP Wed Jun 18 14:15:37 UTC 2008 
x86_64 GNU/Linux

$ cat longlongint.cc
#include <iostream>
#include <string>

using namespace std;

void f(int64_t x) { cout << x << endl; }
void f(int32_t x) { cout << x << endl; }
void f(int16_t x) { cout << x << endl; }
void f(int8_t  x) { cout << x << endl; }
void f(double  x) { cout << x << endl; }
void f(float   x) { cout << x << endl; }
void f(string& x) { cout << x << endl; }

int
main()
{
   long long int x = 32;
   f(x);
   int64_t y = 32;
   f(y);
   f(0LL);
   return 0;
}

$ g++ -pedantic -Wall -Wextra longlongint.cc
longlongint.cc:21:5: warning: use of C99 long long integer constant
longlongint.cc: In function âint main()â:
longlongint.cc:17: error: ISO C++ does not support âlong longâ
longlongint.cc:18: error: call of overloaded âf(long long int&)â is 
ambiguous
longlongint.cc:6: note: candidates are: void f(int64_t)
longlongint.cc:7: note:                 void f(int32_t)
longlongint.cc:8: note:                 void f(int16_t)
longlongint.cc:9: note:                 void f(int8_t)
longlongint.cc:10: note:                 void f(double)
longlongint.cc:11: note:                 void f(float)
longlongint.cc:21: error: call of overloaded âf(long long int)â is ambiguous
longlongint.cc:6: note: candidates are: void f(int64_t)
longlongint.cc:7: note:                 void f(int32_t)
longlongint.cc:8: note:                 void f(int16_t)
longlongint.cc:9: note:                 void f(int8_t)
longlongint.cc:10: note:                 void f(double)
longlongint.cc:11: note:                 void f(float)

-- 
Yang Zhang
http://www.mit.edu/~y_z/



More information about the Gcc-help mailing list