20 issues of porting C++ code on the 64-bit platform
IntroductionWe offer you to read the article devoted to the port of the program code of 32-bit applications on 64-bit systems. The article is written for programmers who use C++ but it may be also useful for all who face the port of applications on other platforms. One should understand properly that the new class of errors which appears while writing 64-bit programs is not just some new incorrect constructions among thousands of others. These are inevitable difficulties which the developers of any developing program will face. This article will help you to be ready for these difficulties and will show the ways to overcome them. Besides advantages, any new technology (in programming and other spheres as well) carries some limitations and even problems of using this technology. The same situation can be found in the sphere of developing 64-bit software. We all know that 64-bit software is the next step of the information technologies development. But in reality, only few programmers have faced the nuances of this sphere and developing 64-bit programs in particular. We won’t dwell on the advantages which the use of 64-bit architecture opens before programmers. There are a lot of publications devoted to this theme and the reader can find them easily. The aim of this article is to observe thoroughly those problems which the developer of 64-bit programs can face. In the article you will learn about:
To make the following text easier for understanding let’s remember some types first which we can face. (see table N1).
We’ll use term "memsize" type in the text. By this we’ll understand any simple integer type which is capable to keep a pointer and changes its size according to the change of the platform dimension form 32-bit to 64-bit. The examples memsize types: size_t, ptrdiff_t, all pointers, intptr_t, INT_PTR, DWORD_PTR. We should say some words about the data models which determine the correspondence of the sizes of fundamental types for different systems. Table N2 contains data models which can interest us.
On default in this article we’ll consider that the program port will be fulfilled from the system with the data model ILP32 on systems with data model LP64 or LLP64. And finally, 64-bit model in Linux (LP64) differs from that in Windows (LLP64) only in the size of long type. So long as it is their only difference, to summarize the account we’ll avoid using long, unsigned long types, and will use ptrdiff_t, size_t types. Let’s start observing the type errors which occur while porting programs on the 64-bit architecture
|
|