www.digitalmars.com         C & C++   DMDScript  

D - DMD 0.69 Bug - CreateFileA

reply J C Calvarese <jcc7 cox.net> writes:
The compiler is telling me that the arguments types don't match, but as 
far as I can tell they do match -- exactly.  I've had similar problems 
in the past with earlier releases of DMD.  I think I solved them by 
overriding the prototype in windows.d (perhaps with "HANDLE 
CreateFileA(LPCSTR, DWORD, DWORD, UINT, DWORD, DWORD, HANDLE);"), but I 
can't see why that would be necessary.  I cast my code until the types I 
send are precisely what the prototype desires, and the compiler is still 
unsatisfied.  I'm trying to compile on WindowsME with DMD 0.69.


function CreateFileA (
char*lpFileName,
uint dwDesiredAccess,
uint dwShareMode,
SECURITY_ATTRIBUTES *lpSecurityAttributes,
uint dwCreationDisposition,
uint dwFlagsAndAttributes,
HANDLE hTemplateFile)
does not match argument types
(char*,uint,uint,SECURITY_ATTRIBUTES ,uint,uint,HANDLE )


Thanks for any help you can provide.

Justin


Here's the offending code...


import string;
import stream;
import windows;

int main(char[][] Args)
{
     int i, j;
     char[] fn = Args[1];
     bit ret;
     char* lpFileName = cast(char*) (fn ~ \0);

     HANDLE hFile = CreateFileA(lpFileName, GENERIC_WRITE, cast(uint) 
(FILE_SHARE_READ || FILE_SHARE_WRITE), cast(SECURITY_ATTRIBUTES) 0, 
cast(uint) OPEN_EXISTING, cast(uint) 0, cast(HANDLE) 0);

     return 0;
}
Aug 16 2003
next sibling parent "Mike Wynn" <mike.wynn l8night.co.uk> writes:
"J C Calvarese" <jcc7 cox.net> wrote in message
news:bhlqv0$2rg0$1 digitaldaemon.com...
 The compiler is telling me that the arguments types don't match, but as
 far as I can tell they do match -- exactly.  I've had similar problems
 in the past with earlier releases of DMD.  I think I solved them by
 overriding the prototype in windows.d (perhaps with "HANDLE
 CreateFileA(LPCSTR, DWORD, DWORD, UINT, DWORD, DWORD, HANDLE);"), but I
 can't see why that would be necessary.  I cast my code until the types I
 send are precisely what the prototype desires, and the compiler is still
 unsatisfied.  I'm trying to compile on WindowsME with DMD 0.69.


 function CreateFileA (
 char*lpFileName,
 uint dwDesiredAccess,
 uint dwShareMode,
 SECURITY_ATTRIBUTES *lpSecurityAttributes,
^^ NOTE THIS LINE
 uint dwCreationDisposition,
 uint dwFlagsAndAttributes,
 HANDLE hTemplateFile)
 does not match argument types
 (char*,uint,uint,SECURITY_ATTRIBUTES ,uint,uint,HANDLE )
^^ see anything yet ?
 Thanks for any help you can provide.

 Justin


 Here's the offending code...


 import string;
 import stream;
 import windows;

 int main(char[][] Args)
 {
      int i, j;
      char[] fn = Args[1];
      bit ret;
      char* lpFileName = cast(char*) (fn ~ \0);

      HANDLE hFile = CreateFileA(lpFileName, GENERIC_WRITE, cast(uint)
 (FILE_SHARE_READ || FILE_SHARE_WRITE), cast(SECURITY_ATTRIBUTES) 0,
should be `null`, cast(SECURITY_ATTRIBUTES*)null, or cast(SECURITY_ATTRIBUTES*)0 // you've missed the `*`
 cast(uint) OPEN_EXISTING, cast(uint) 0, cast(HANDLE) 0);

      return 0;
 }
Aug 16 2003
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
Change:

    cast(SECURITY_ATTRIBUTES) 0

to:

    cast (SECURITY_ATTRIBUTES*) 0

"J C Calvarese" <jcc7 cox.net> wrote in message
news:bhlqv0$2rg0$1 digitaldaemon.com...
 The compiler is telling me that the arguments types don't match, but as
 far as I can tell they do match -- exactly.  I've had similar problems
 in the past with earlier releases of DMD.  I think I solved them by
 overriding the prototype in windows.d (perhaps with "HANDLE
 CreateFileA(LPCSTR, DWORD, DWORD, UINT, DWORD, DWORD, HANDLE);"), but I
 can't see why that would be necessary.  I cast my code until the types I
 send are precisely what the prototype desires, and the compiler is still
 unsatisfied.  I'm trying to compile on WindowsME with DMD 0.69.


 function CreateFileA (
 char*lpFileName,
 uint dwDesiredAccess,
 uint dwShareMode,
 SECURITY_ATTRIBUTES *lpSecurityAttributes,
 uint dwCreationDisposition,
 uint dwFlagsAndAttributes,
 HANDLE hTemplateFile)
 does not match argument types
 (char*,uint,uint,SECURITY_ATTRIBUTES ,uint,uint,HANDLE )


 Thanks for any help you can provide.

 Justin


 Here's the offending code...


 import string;
 import stream;
 import windows;

 int main(char[][] Args)
 {
      int i, j;
      char[] fn = Args[1];
      bit ret;
      char* lpFileName = cast(char*) (fn ~ \0);

      HANDLE hFile = CreateFileA(lpFileName, GENERIC_WRITE, cast(uint)
 (FILE_SHARE_READ || FILE_SHARE_WRITE), cast(SECURITY_ATTRIBUTES) 0,
 cast(uint) OPEN_EXISTING, cast(uint) 0, cast(HANDLE) 0);

      return 0;
 }
Aug 16 2003
next sibling parent reply J C Calvarese <jcc7 cox.net> writes:
Thanks a bunch.  (Don't I feel stupid?)  That fixed my problem.

Walter wrote:
 Change:
 
     cast(SECURITY_ATTRIBUTES) 0
 
 to:
 
     cast (SECURITY_ATTRIBUTES*) 0
 
Aug 16 2003
parent "Walter" <walter digitalmars.com> writes:
You shouldn't feel stupid. The error message spit out by the compiler was
inadequate, and is what is to blame here.

"J C Calvarese" <jcc7 cox.net> wrote in message
news:bhm60h$7vh$1 digitaldaemon.com...
 Thanks a bunch.  (Don't I feel stupid?)  That fixed my problem.

 Walter wrote:
 Change:

     cast(SECURITY_ATTRIBUTES) 0

 to:

     cast (SECURITY_ATTRIBUTES*) 0
Aug 16 2003
prev sibling parent "Philippe Mori" <philippe_mori hotmail.com> writes:
IMO we should be able to pass null keyword for a null pointer without any
cast...

In C++, it was an error that 0 and NULL are equivalent. Although we can
support 0 to initialize a pointer, a nill constant that would be assignable
only
to pointer would be better and would help avoid ambiguities (0 would always
match integral if possible)

and if we like documenting null parameters, we could then declare a null
constant of the proper type (nil_security_attributes).


"Walter" <walter digitalmars.com> a écrit dans le message de
news:bhlvvb$3102$1 digitaldaemon.com...
 Change:

     cast(SECURITY_ATTRIBUTES) 0

 to:

     cast (SECURITY_ATTRIBUTES*) 0

 "J C Calvarese" <jcc7 cox.net> wrote in message
 news:bhlqv0$2rg0$1 digitaldaemon.com...
 The compiler is telling me that the arguments types don't match, but as
 far as I can tell they do match -- exactly.  I've had similar problems
 in the past with earlier releases of DMD.  I think I solved them by
 overriding the prototype in windows.d (perhaps with "HANDLE
 CreateFileA(LPCSTR, DWORD, DWORD, UINT, DWORD, DWORD, HANDLE);"), but I
 can't see why that would be necessary.  I cast my code until the types I
 send are precisely what the prototype desires, and the compiler is still
 unsatisfied.  I'm trying to compile on WindowsME with DMD 0.69.


 function CreateFileA (
 char*lpFileName,
 uint dwDesiredAccess,
 uint dwShareMode,
 SECURITY_ATTRIBUTES *lpSecurityAttributes,
 uint dwCreationDisposition,
 uint dwFlagsAndAttributes,
 HANDLE hTemplateFile)
 does not match argument types
 (char*,uint,uint,SECURITY_ATTRIBUTES ,uint,uint,HANDLE )


 Thanks for any help you can provide.

 Justin


 Here's the offending code...


 import string;
 import stream;
 import windows;

 int main(char[][] Args)
 {
      int i, j;
      char[] fn = Args[1];
      bit ret;
      char* lpFileName = cast(char*) (fn ~ \0);

      HANDLE hFile = CreateFileA(lpFileName, GENERIC_WRITE, cast(uint)
 (FILE_SHARE_READ || FILE_SHARE_WRITE), cast(SECURITY_ATTRIBUTES) 0,
 cast(uint) OPEN_EXISTING, cast(uint) 0, cast(HANDLE) 0);

      return 0;
 }
Aug 16 2003