Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integer types use #21

Open
vladak opened this issue Mar 23, 2021 · 1 comment
Open

integer types use #21

vladak opened this issue Mar 23, 2021 · 1 comment

Comments

@vladak
Copy link
Member

vladak commented Mar 23, 2021

Add a module on when to use size_t and when other integer types.

E.g. https://stackoverflow.com/questions/131803/unsigned-int-vs-size-t

Plus examples on working with file offset (seek, read, write, ...), etc.
The size_t type is the unsigned integer type that is the result of the sizeof
operator (and the offsetof operator), so it is guaranteed to be big enough to
contain the size of the biggest object your system can handle (e.g., a static
array of 8Gb).

Also add an idea to use 'u' for an unsigned integer in for

@vladak
Copy link
Member Author

vladak commented Mar 23, 2021

Related to the int/size_t discussion above, make a new module for uint32_t et
al. It is in the spec as part of stdint.h.

7.18.1.1 Exact-widthinteger types1The typedef nameintN_tdesignates a signed
integer type with widthN,nopaddingbits, and a two’scomplement
representation.Thus,int8_tdenotes a signed integertype with a width of
exactly 8 bits.2The typedef nameuintN_tdesignates an unsigned integer type
with widthN.Thus,uint24_tdenotes an unsigned integer type with a width of
exactly 24 bits.3These types are optional.However, ifanimplementation
provides integer types withwidths of 8, 16, 32, or 64 bits, no
padding bits, and (for the signed types) that have atwo’scomplement
representation, it shall define the corresponding typedef names

vladak pushed a commit that referenced this issue Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant