C and C++ notes / Types and values, and strings: Difference between revisions

From Helpful
Jump to navigation Jump to search
mNo edit summary
Line 110: Line 110:




Pointer size is also implied by architecture. There are a few acronyms used to refer to how different systems do things. For example,  
Pointer size is also implied by architecture.  
There are a few acronyms used to refer to how different systems do things. For example,  
* Most 64-bit unices are LP64
* Most 64-bit unices are LP64
* 64-bit windows is LLP64
* 64-bit windows is LLP64
* 32-bit windows and most 32-bit unices are ILP32. (long long being either not explicitly settled, or settled at 64-bit)
* 32-bit windows and most 32-bit unices are ILP32. (long long being either not explicitly settled, or settled at 64-bit)


More of them:
More of them:
Line 122: Line 124:
  LP64            64      (32)    64      (64)                   
  LP64            64      (32)    64      (64)                   
  ILP64            64        64      64      (64)
  ILP64            64        64      64      (64)
Notes:
Notes:
* refers to size of long & pointer, int & long & pointer, or long-long & pointer
* refers to size of long & pointer, int & long & pointer, or long-long & pointer
* Bracketed values are those that seem to be implied{{verify}} rather than explicitly settled
* Bracketed values are those that seem to not be settled, but so typical you can consider them implied unless settled otherwise{{verify}}


* The safest, most portable use of integer types is to use specific-sized integers (or, almost as good: always use long long).
* The safest, most portable use of integer types is to use specific-sized integers (or, ''almost'' as good as advice: "always use long long if you mean that").


* Enough programmers make bad assumptions based on their machines, which may not be true when compiled on a another or a later architecture. Often simple enough to fix since it was based on a specific size.
* Enough programmers make bad assumptions based on their machines, which may not be true when compiled on a another or a later architecture. Often simple enough to fix since it was based on a specific size.

Revision as of 17:11, 27 February 2024

Notes related to C and C++

Note: Some notes describe behaviour common to most variants - for C mostly meaning C89 (and a bit of C99), unless mentioned otherwise.

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

Types, specifiers, properties, and such

Type specification

Type conversion

Type juggling

On integer and pointer size