www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - INVALID_HANDLE_VALUE const?

reply Regan Heath <regan netmail.co.nz> writes:
in std.c.windows.windows we have;

final HANDLE INVALID_HANDLE_VALUE = cast(HANDLE)-1;
const DWORD INVALID_SET_FILE_POINTER = cast(DWORD)-1;
const DWORD INVALID_FILE_SIZE = cast(DWORD)0xFFFFFFFF;

Why is INVALID_HANDLE_VALUE not const like the others?

It means when you try to use it like..

class Foo
{
   HANDLE bar = INVALID_HANDLE_VALUE;
}

you get an error.

Regan
Jul 13 2007
parent Lionello Lunesu <lio lunesu.remove.com> writes:
Regan Heath wrote:
 in std.c.windows.windows we have;
 
 final HANDLE INVALID_HANDLE_VALUE = cast(HANDLE)-1;
 const DWORD INVALID_SET_FILE_POINTER = cast(DWORD)-1;
 const DWORD INVALID_FILE_SIZE = cast(DWORD)0xFFFFFFFF;
 
 Why is INVALID_HANDLE_VALUE not const like the others?

Isn't HANDLE aliased as a void*? I guess you can't have a const (void*). Just a guess. L.
Jul 16 2007