JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.3: C User's Guide     Oracle Solaris Studio 12.3 Information Library
search filter icon
search icon

Document Information

Preface

1.  Introduction to the C Compiler

2.  C-Compiler Implementation-Specific Information

3.  Parallelizing C Code

4.  lint Source Code Checker

5.  Type-Based Alias Analysis

6.  Transitioning to ISO C

7.  Converting Applications for a 64-Bit Environment

7.1 Overview of the Data Model Differences

7.2 Implementing Single Source Code

7.2.1 Derived Types

7.2.1.1 <sys/types.h>

7.2.1.2 <inttypes.h>

Fixed-Width Integer Types

Helpful Types Such as unintptr_t

Constant Macros

Limits

Format String Macros

7.2.2 Checking With lint

7.3 Converting to the LP64 Data Type Model

7.3.1 Integer and Pointer Size Change

7.3.2 Integer and Long Size Change

7.3.3 Sign Extension

7.3.4 Pointer Arithmetic Instead of Integers

7.3.5 Structures

7.3.6 Unions

7.3.7 Type Constants

7.3.8 Beware of Implicit Declarations

7.3.9 sizeof( ) Is an Unsigned long

7.3.10 Use Casts to Show Your Intentions

7.3.11 Check Format String Conversion Operation

7.4 Other Conversion Considerations

7.4.1 Note: Derived Types That Have Grown in Size

7.4.2 Check for Side Effects of Changes

7.4.3 Check Literal Uses of long Still Make Sense

7.4.4 Use #ifdef for Explicit 32-bit Versus 64-bit Prototypes

7.4.5 Calling Convention Changes

7.4.6 Algorithm Changes

7.5 Checklist for Getting Started

8.  cscope: Interactively Examining a C Program

A.  Compiler Options Grouped by Functionality

B.  C Compiler Options Reference

C.  Implementation-Defined ISO/IEC C99 Behavior

D.  Features of C99

E.  Implementation-Defined ISO/IEC C90 Behavior

F.  ISO C Data Representations

G.  Performance Tuning

H.  Oracle Solaris Studio C: Differences Between K&R C and ISO C

Index

7.1 Overview of the Data Model Differences

The biggest difference between the 32-bit and the 64-bit compilation environments is the change in data-type models.

The C data-type model for 32-bit applications is the ILP32 model, so named because integers, longs, and pointers are 32-bit data types. The LP64 data model, so named because longs and pointers grow to 64-bits, is the creation of a consortium of companies across the industry. The remaining C types, int, long long, short, and char, are the same in both data-type models.

Regardless of the data-type model, the standard relationship between C integral types holds true:

sizeof (char) <= sizeof (short) <= sizeof (int) <= sizeof (long)

The following table lists the basic C data types and their corresponding sizes in bits for both the ILP32 and LP64 data models.

Table 7-1 Data Type Size for ILP32 and LP64

C Data Type
ILP32
LP64
char
8
8
short
16
16
int
32
32
long
32
64
long long
64
64
pointer
32
64
enum
32
32
float
32
32
double
64
64
long double
128
128

current 32-bit applications typically assume that integers, pointers, and longs are the same size. However, the size of longs and pointers changes in the LP64 data model, which can cause many ILP32 to LP64 conversion problems.

In addition, declarations and casts are very important. How expressions are evaluated can be affected when the types change. The effects of standard C conversion rules are influenced by the change in data-type sizes. To adequately show what you intend, you need to explicitly declare the types of constants. You can also use casts in expressions to make certain that the expression is evaluated the way you intend. This practice is particularly important with sign extension, where explicit casting is essential for demonstrating intent.