Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux 32 位元與 64 位元系統基本資料型態長度差異對照表

編輯:關於 Linux

移植 C/C++ 程式碼至不同架構時,基本型態長度差異是常見坑點。本文對照 ILP32、LP64、LLP64 三種資料模型下的型態位元寬度。

基本型態長度對照

型態ILP32 (32-bit)LP64 (64-bit Linux/Unix)LLP64 (64-bit Windows)
char888
short161616
int323232
long326432
long long646464
pointer326464

固定寬度型態 (推薦跨平台使用)

int32_t, uint32_t  // 確切 32 位
int64_t, uint64_t  // 確切 64 位

特殊型態

  • size_t:與機器字長一致 (ILP32=32, LP64=64)。
  • off_t:32 位系統預設 32 位,無法操作 >4GB 檔案。需定義 _FILE_OFFSET_BITS 64 使其變為 64 位 (off64_t);64 位系統預設 64 位。
  • ino_t:與機器字長一致。

理解模型差異,編寫可移植程式碼時優先使用固定寬度型態與大檔案支援宏。

Copyright © Windows教程網 All Rights Reserved