This topic is now archived and is closed to further replies.

original vesoljc

__int64 & error C2593: 'operator <<' is ambiguous

Recommended Posts

ApochPiQ    23004
cout doesn''t have a << operator defined for 64 bit ints. There''s your why

As to solving it, I''m not sure. I''ve only used __int64s with *printf so I can''t say how to work around it with cout. I''m very evil with my C/C++ programming and often mix C-style functions with C++ code just to get around issues like this. That''s my best offer; maybe someone else knows a better way?

Share this post

Link to post
Share on other sites
Russell    118
I use unsigned __int64 a great deal in my programs, and the only way I know of to print the value is to use printf() (unless you want to write your own, which isn''t difficult, but might as well use printf then...).

unsigned __int64 i = Some64BitValue();
printf("%I64u\n", i);

In VC++ you add I64 to printf, as shown above. For instance:

%d becomes %I64d
%u becomes %I64u
%x becomes %I64x

and so on...

I think gcc and maybe the Intel compiler use %ll instead of %I64. So you would do %llu instead of %I64u, etc. You can write some #define''s to handle this so your code will compile in VC++ and gcc if that is needed.

Share this post

Link to post
Share on other sites