Вопрос Почему в коде чаще используют DWORD а не int

Начинающий
Статус
Оффлайн
Регистрация
17 Июн 2023
Сообщения
23
Реакции[?]
4
Поинты[?]
5K
потому что DWORD обеспечивыет совместимость со всеми совмястимостями и заголовками windows
 
эксперт в майнкрафт апи
Read Only
Статус
Оффлайн
Регистрация
25 Янв 2023
Сообщения
684
Реакции[?]
287
Поинты[?]
22K
ну и ващет dword это unsinged int32 а не int32
 
Ревёрсер среднего звена
Пользователь
Статус
Оффлайн
Регистрация
24 Ноя 2022
Сообщения
303
Реакции[?]
107
Поинты[?]
56K
Эксперт
Статус
Оффлайн
Регистрация
29 Мар 2021
Сообщения
1,572
Реакции[?]
594
Поинты[?]
33K
эксперт в майнкрафт апи
Read Only
Статус
Оффлайн
Регистрация
25 Янв 2023
Сообщения
684
Реакции[?]
287
Поинты[?]
22K
верно, особенно про совместимость с совместимостями


sizeof(uint32_t) != sizeof(uintptr_t)
C99
Код:
7.18.1.4 Integer types capable of holding object pointers
1 The following type designates a signed integer type with the property that any valid
pointer to void can be converted to this type, then converted back to pointer to void,
and the result will compare equal to the original pointer:
intptr_t
The following type designates an unsigned integer type with the property that any valid
pointer to void can be converted to this type, then converted back to pointer to void,
and the result will compare equal to the original pointer:
uintptr_t
These types are optional.
Stackoverflow:
Код:
uintptr_t might be the same size as a void*. It might be larger. It could conceivably be smaller, although such a C++ implementation approaches perverse. For example on some hypothetical platform where void* is 32 bits, but only 24 bits of virtual address space are used, you could have a 24-bit uintptr_t which satisfies the requirement. I don't know why an implementation would do that, but the standard permits it.
Но в целом да, это энивей не раскрывает тайну почему sizeof(uintptr_t) должен быть эквивалентен sizeof(uint32_t)
 
Эксперт
Статус
Оффлайн
Регистрация
29 Мар 2021
Сообщения
1,572
Реакции[?]
594
Поинты[?]
33K
C99
Код:
7.18.1.4 Integer types capable of holding object pointers
1 The following type designates a signed integer type with the property that any valid
pointer to void can be converted to this type, then converted back to pointer to void,
and the result will compare equal to the original pointer:
intptr_t
The following type designates an unsigned integer type with the property that any valid
pointer to void can be converted to this type, then converted back to pointer to void,
and the result will compare equal to the original pointer:
uintptr_t
These types are optional.
Stackoverflow:
Код:
uintptr_t might be the same size as a void*. It might be larger. It could conceivably be smaller, although such a C++ implementation approaches perverse. For example on some hypothetical platform where void* is 32 bits, but only 24 bits of virtual address space are used, you could have a 24-bit uintptr_t which satisfies the requirement. I don't know why an implementation would do that, but the standard permits it.
Но в целом да, это энивей не раскрывает тайну почему sizeof(uintptr_t) должен быть эквивалентен sizeof(uint32_t)
Дело в том, что int будет занимать 4 байта (x86+).
uintptr же.. ты описал ;)
 
эксперт в майнкрафт апи
Read Only
Статус
Оффлайн
Регистрация
25 Янв 2023
Сообщения
684
Реакции[?]
287
Поинты[?]
22K
Дело в том, что int будет занимать 4 байта (x86+).
uintptr же.. ты описал ;)
речь хоть и про x86+(dword), но в целом это не имеет сути изза разной семантики этих типов.
ждем комментарий ExistedDim4 :CoolCat:
upd:
dword отнес к x86 притянуто за уши разумеется
превентивный удар 😌
 
Последнее редактирование:
Эксперт
Статус
Оффлайн
Регистрация
29 Мар 2021
Сообщения
1,572
Реакции[?]
594
Поинты[?]
33K
отвечая на вопрос автора - нет, не используют. сумасшедшие индусы, что работают в майкрософт - не все. их кодстиль адаптировать не советую никому.
 
эксперт в майнкрафт апи
Read Only
Статус
Оффлайн
Регистрация
25 Янв 2023
Сообщения
684
Реакции[?]
287
Поинты[?]
22K
отвечая на вопрос автора - нет, не используют. сумасшедшие индусы, что работают в майкрософт - не все. их кодстиль адаптировать не советую никому.
бля, резюмируя :
dword существует только в реалиях windows.h, стандарт c++ к нему никак не относится
 
Сверху Снизу