-
September 4th, 2022, 12:57 AM
#1
fixed width variables
hi,
can i use int8_t, int16_t, int32_t, int64_t, and uint8_t, uint16_t, uint32_t, uint64_t,to make sure the widths do not change from different versions of visual studio?. Like one version might handle unsigned int as 4 bytes and another version might handle it as 8 bytes.
Last edited by @EE@; September 13th, 2022 at 01:00 AM.
-
September 13th, 2022, 01:02 AM
#2
Re: question on structures
-
September 13th, 2022, 01:44 AM
#3
Re: question on structures
Victor Nijegorodov
-
September 13th, 2022, 03:35 AM
#4
Re: question on structures
can i use int8_t, int16_t, int32_t, int64_t, and uint8_t, uint16_t, uint32_t, uint64_t,to make sure the widths do not change from different versions of visual studio?
Basically, yes. Note though that int8_t is usually treated as a type char (eg for std::cout). Also note that .size() and std::size() return type is size_t whose width does change depending upon whether compiling for 32 or 64 bit.
Although it is unlikely that widths would change between versions of VS. Note though, that various MS specific types (defined in windows.h) that relate to pointers do change size depending upon whether compiling for 32 or 64 bit. In existing 32 bit code if any 32 bit variable is used to hold a memory address (typically DWORD) then this code will not be correct if compiled for 64 bit. Windows data types also include specific widths. See
https://docs.microsoft.com/en-us/win...ows-data-types
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|