On 1/3/21 10:40 AM, Paul Procacci wrote:
Irrelevant musings:
--
A windows handle is a pointer.
A handle is an abstraction to a memory location that can be used in
subsequent api calls.
Declaring it as any incarnation of an int is a mistake and will not
function properly across all machines.
Here is a nice description of the difference:
https://stackoverflow.com/questions/13023405/what-is-the-difference-between-handle-pointer-and-reference
A handle is usually an opaque reference to an object.
The type of the handle is unrelated to the element
referenced. Consider for example a file descriptor
returned by open() system call. The type is int but
it represents an entry in the open files table. The
actual data stored in the table is unrelated to the
int that was returned by open() freeing the
implementation from having to maintain compatibility
(i.e. the actual table can be refactored transparently
without affecting user code. Handles can only be used
by functions in the same library interface, that can
remap the handle back to the actual object.
A pointer is the combination of an address in memory
and the type of the object that resides in that
memory location. The value is the address, the
type of the pointer tells the compiler what
operations can be performed through that pointer,
how to interpret the memory location. Pointers
are transparent in that the object referenced
has a concrete type that is present from the
pointer. Note that in some cases a pointer can
serve as a handle (a void* is fully opaque, a
pointer to an empty interface is just as opaque).