-
64 Bit Compadibility?
Most of my code is simple C++ console utils, using stl components that compile fine between most OS's. Im wondering what type of complications i can expect to deal with should i try and compile and run my software on a 64bit pooter. Any input? Thanks guys.
-
If your code makes any assumptions about the size of data types (i.e. the maximum integer value), then it will run into trouble. If it does not need to make such assumptions, or accounts for possible differences (checking numerical limit values, using arbitrary precision number packages, etc), then it will not be affected.
-
I would think most problems would not be in your code but in the compiler because most compilers (if not all) are platform/family specific. Like
for gcc for example you can get
i386 (runs on almost all intel familys)
i586
and i686 (correct me if im wrong)
and then they have one for SPARC etc.
and I believe... that the code on a 64bit system would compile fine (unless something like the above post happens) proveded that the compiler is equipped to handle the environment on this system.
These are assumptions based off what I have learned, so correct me if i'm wrong anywhere.
-LC
-
Im worried about math as well. If i perform division or another operation with certain significant figures, decimal places might go out more digits, and later on when i round, the answers between a 64bit and 32bit system might differ. Things of this nature are concieveable right?
-
well 64bit systems can run 32bit modes so technically all of the above shouldn't matter at all.
-LC
-
If your worried about such problems, you can check the std::numeric_limits templated structure in <limits>. For foating point types, it tells you the size of the mantissa, minimum and maximum exponents, epsilon, etc. For integral types, it tells you number of bits, min and max, signed, etc. Most likely, you'd have more problems (perhaps not errors, but losses of expected precision) moving from 64-bits to 32-bits, not vice-versa.
-
ok here is my reasoning
everything will run the same because the processor will simply use a 32 bit mode, you have to do special types of programming to take advantage of the 64bit modes and registers. very few compilers are equipped to handle this I think only gcc and MSVC++ 7 are the only two right now. If the are even able to do so. Very few things can access the 64bit registers etc. The CPU, I believe, will do most of that work for you. If you want I can write some C to ASM code here to show you that it won't make a difference, especially if you use a compiler that was designed for a 32bit system. It is only if your code is specifically designed for the 64bit system will it matter at all. The compiler doesn't know how to use the new registers and all the new capabilities so it just uses the old ones and thats fine. So don't worry about it ^_^
-LC
-
Many compilers for other 64 bit platforms do take advantage of the 64-bit processors (e.g. MIPSPro). The thing is, if you use things such as INT_MAX instead of hard-coding values like 2^31-1 (as the max signed integer) or the the numeric_limits templates should you need them, you should be fine.
-
C++ is PORTABLE !
C and C++ are portable languages. If you write to the ANSI/ISO standard, you can compile you code for any platform for which you have a compliant compiler.
Like Zack said, you can use <limits> if necessary. The standard does specify a minimum size for each type. (A char MUST hold at least 8 bytes, etc.)
Most real-world programs will have non-standard code. I'm sure it's considered good-practice to put all of the non-standard code in separate modules... but if you're writing Windows programs 90 percent of it's going to be non-standard!