Why is using "long long" in C or C ++ bad?

Why is using "long long" in C or C ++ bad?

I have compiled a runtime library the other day and in the code that it checks to determine if 64 bits are long and if they are not used for a long time. But along with this, it sends #warning "using long long". I can not think of any reason for the "long long" to be a warning if he did not leave the debugging work from the developer.

Thanks Chenz

+4
source share
4 answers

As far as I know, long long is currently standard only on C99. It will also be a type in C ++ 0x, but most modern compilers should already support it.

However, for integers of a fixed size, you can use the header C99 <stdint.h> or in C ++ <boost/cstdint.hpp>

+10
source

Two reasons:

You do not know how long (ha ha!) A long time is, so if the code assumes that it is exactly 64 bits, a problem may arise.

If you use the old C compiler, it may not support for a long time.

+9
source

I agree with Thomas Padron-McCarth. It is much better to check for int64_t (signed) or uint64_t (unsigned), respectively, and use them if they exist. This is the same sanity that led to size_t.

+7
source

Not tolerated. In particular, the Windows compiler was not used for long support, and instead you had to use __int64 and unsigned __int64 (but could not use them necessarily for use on platforms other than Windows).

This was some time ago, so there may now be more chances to always have uint64_t and int64_t available.

+5
source

All Articles