LONG is a Window data-type that’s defined as using the complier’s 32-bit integer type.
long is a C/C++ intrinsic datatype of indeterminate size
With the MS compiler LONG happens to be defined as long. With another compiler it might be defined as int.
-p
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Tuesday, May 5, 2015 9:30 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] convert LARGE_INTEGER to DWORD
xxxxx@osr.com wrote:
There you’re exactly correct. There’s a reason “they” defined a unique abstract set of kernel-mode data types when Windows NT was being developed.
It’s really, really hard to defend the argument that “ULONG” is somehow an abstraction of “unsigned long”. DWORD is an abstraction, and that’s what should have been used for ALL 32-bit types in the kernel. The CHAR, UCHAR, SHORT, USHORT, INT, UINT, LONG and ULONG types are idiotic and have been all along. No one in their right might would ever have defined ULONG be anything other than “unsigned long”. Therefore, it’s not an abstraction. It’s a typing shortcut.
Had DWORD been used throughout, Microsoft could have changed “long” to 64-bits without any impact. In my view, that would have been a much more sensible approach. There was ample existing prior art for other 64-bit platforms that demonstrated the viability of that choice.
It was to purposefully separate them from the native system/compiler data types, and provide portability for kernel-mode code.
Do you really believe that “LONG” is separate from “long”? Really?
If you want to air personal datatype annoyances, MY biggest one is the C# datatypes. char in C# is 2 bytes, and long is 64-bits. Very, very, very annoying. I had my lead check-in a whole series of changes to a rather high visibility project once with the explanation “Changed ‘char’ by ‘byte’ everywhere, because Peter apparently didn’t realize ‘char’ was 2 bytes” Very embarrassing.
To be fair, that problem occurred was not because the choices in C# are bad. It’s because you were approaching C# with C firmly lodged in your brain. The decision to have char be 2 bytes is quite defensible. Easy internationalization is more important than programmer familiarity.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer