Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼


Porting to 64-bit Platforms

Irving Rabin is a Senior Consultant for Code Integrity Solutions, a consultancy for static source code analysis professional services. Irving is a former architect at Vitria Technologies, Principal Software Engineer at Openwave, and Research and Development Manager at Platinum Technologies.

C and C++ rely heavily on usage of pointers, i.e. variables containing memory addresses. While pointer types are conceptually different from integer types, the physical address is always an integer number. Developers heavily use integer types instead of pointer types in C/C++, even in system headers that come with compilers.

For the last few decades most computer processors used 32-bit memory addresses, so development environments have been built around the assumption that addresses are 32-bit long. Implicit and explicit casting between pointers and integers and overlapping memory structures through pointers or unions became commonplace.

Of course, 32-bit architectures have its limitation; specifically they limit computer memory to 4GB. Application requirements have grown and migration to longer addresses was imminent. While first 64-bit computers have been introduced in the 1970s, only in the mid-1990s did major corporations start releasing 64-bit processors to the market on a larger scale. With a new architecture came the arrival of new operating systems. And, the new architecture brought new meaning and values to the well-known, frequently used legacy types. The most dramatic change was moving to 64-bit pointers. The need to adjust to the new sizes of integer types was apparent.

The Same Rules No Longer Apply

Some of the sizes of the base types changed. Some of them remain the same. However a multitude of implicit assumptions used all over C and C++ code bases suddenly was no longer valid. The code written and tested in 32-bit system was no longer valid with migration to 64-bit computers.

Fortunately, most of the areas where the code may be vulnerable to migration from 32-bit machines to 64-bit machines have been identified and classified. Some of the compilers use aggressive checking techniques to catch possible vulnerabilities expected during migration. Vendors of static analysis tools -- Coverity and Klocwork come to mind -- provide mechanisms that further assist smooth code migration from 32-bit to 64-bit machines. While these tools do not directly address code migration, they provide convenient extensibility and APIs to create customized checkers relevant to 32-bit to 64-bit migration. Augmenting these tools can help even further to uncover and efficiently fix these compatibility problems.

The goal of this article is to help you make your code base architecture-independent, so the same codebase can be built on either a 32-bit machine or 64-bit machine and produce workable code for each machine. Furthermore, if 32-bit programs communicate with 64-bit programs through binary data exchange (through files or sockets), there are ways to make sure that binary structures are immune to migration between the two architecture types.

This article contains detailed analysis and recommendations for dealing with a multitude of issues related to 32-bit to 64-bit migration.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.