gpt4 book ai didi

c# - Word16 和 UWord16 的混淆

转载 作者:行者123 更新时间:2023-11-30 21:04:29 24 4
gpt4 key购买 nike

我正在将一些 C 代码移植到 C#。我看到很多 Word16Word32 用法,以及 UWord16UWord32

我知道 Word32 是一个无符号的 32 位 int 类型,但是为什么需要用不同的名称来编写它 UWord32?我在这里错过了什么吗?它在某些方面与 Word32 不同吗?

此外,WORD32 是否可以将其在 C# 中的用法替换为 int?如果不是,为什么?

This Source ,表示WORD是无符号整型。是的,来源是 Haskell,我找不到任何其他解释数据类型 WORD 的文档。

最佳答案

but what could have been the need to write it with a different name UWord32?

这是一个无符号的 32 位整数类型。

通常,您可能会替换(迁移到 C#):

WORD32 -> int (Int32)

UWORD32 -> uint (UInt32)

WORD16 -> (Int16)

UWORD16 -> ushort (UInt16)

然而,鉴于您所显示的命名方案,这都是基于我的预期的所有推测。

请注意,如果您使用的是 Windows Data TypesWORD -> ushortDWORD -> uint。有符号类型是INT/INT32 -> int,然后是INT16 -> short, INT64 -> long

也就是说,所有这些选项都是用 C 或 C++ 定义的,而不是“本地”(语言定义的)类型。如果选择的话,您的代码可以定义 WORD 来表示一个无符号的 64 位整数。因此,您需要查看定义的来源(我在此处列出了 Windows API 标准)。


I know Word32 is an unsigned 32bit int type, but what could have been the need to write it with a different name UWord32?

如果是这种情况,可能不需要为同一类型定义两个。可能是您使用的两个 header 定义的内容略有不同。同样,您需要检查您正在使用的定义这些类型的 header ,并查看它们是如何指定的。

关于c# - Word16 和 UWord16 的混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12322440/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com