I’m porting some C code to C#. I’m seeing a lot of Word16, Word32 usage, along with UWord16and UWord32.
I know Word32 is an unsigned 32bit int type, but what could have been the need to write it with a different name UWord32? Am I missing something here? Is it different from Word32 in some manner?
Also, WORD32 can I just replace its usage in C# with int? If not, why?
This Source, says WORD is an unsigned integral type. Yes the source is of Haskell, I couldn’t find any other documentation explaining the datatype WORD.
This is an unsigned 32 bit integer type.
In general, you can likely replace (moving to C#):
WORD32->int(Int32)UWORD32->uint(UInt32)WORD16->short(Int16)UWORD16->ushort(UInt16)This is, however, all speculation based on my expectations given the naming scheme you’ve shown.
Note that, if you’re using Windows Data Types,
WORD->ushort, andDWORD->uint. Signed types areINT/INT32->int, and thenINT16->short,INT64->long, etc.That being said, all of these options are all defines in C or C++, and not “native” (language defined) types. Your code could define
WORDto represent an unsigned 64 bit integer, if it chose. As such, you need to look at where the defines are coming from (I listed the Windows API standards here).If this is the case, there is likely no need to have two definitions for the same type. It may be that two headers you are using define things slightly different. Again, you’d need to check the headers you’re using that define these types, and see how they’re specified.