www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Compiler not recognizing certain structs, types?

reply V <v pathlink.com> writes:
I'm getting weird errors from the compiler about certain win32 types 
that I have to declare like:

alias void (* LPWSAOVERLAPPED_COMPLETION_ROUTINE)(in DWORD, in DWORD, in 
LPWSAOVERLAPPED, in DWORD);


Then import certain functions like:

extern(Windows)
{
int WSASend(SOCKET s,
	LPWSABUF,
	DWORD,
	LPDWORD,
	DWORD,
	LPWSAOVERLAPPED,
	LPWSAOVERLAPPED_COMPLETION_ROUTINE);
}

And the error happens here:

if (WSASend(client.socket, &buffer, 1, &sent, 0, &client.sendoverlapped, 
&sendCompletion) && WSAGetLastError() != WSA_IO_PENDING)



Errors:

function network.WSASend (uint,WSABUF *,uint,uint*,uint,WSAOVERLAPPED 
*,int(Windows *)(HANDLE,uint,uint,int)) does not match argument types 
(uint,WSABUF *,int,uint*,int,WSAOVERLAPPED *,void(Windows *)(uint 
dwError,uint cbTransferred,WSAOVERLAPPED *lpOverlapped,uint dwFlags))

cannot implicitly convert expression (#buffer) of type WSABUF * to WSABUF *

cannot implicitly convert expression (#*(client).sendoverlapped) of type 
WSAOVERLAPPED * to WSAOVERLAPPED *

cannot implicitly convert expression (#SendCompletion) of type 
void(Windows *)(uint dwError,uint cbTransferred,WSAOVERLAPPED 
*lpOverlapped,uint dwFlags) to void(Windows *)(uint,uint,WSAOVERLAPPED 
*,uint)
Apr 21 2005
next sibling parent reply Manfred Nowak <svv1999 hotmail.com> writes:
V <v pathlink.com> wrote:

[...]
 cannot implicitly convert expression (#buffer) of type WSABUF *
 to WSABUF * 

You may want to check your source for multiple typedef's of `WSABUF'. -manfred
Apr 21 2005
next sibling parent reply V <v pathlink.com> writes:
After some searching I found this:

alias WSABUF* LPWSABUF;

I commented that out and changed all instances of LPWSABUF with WSABUF* 
and magically that error disappeared, but the other 3 remain.

:(
:confused:



Manfred Nowak wrote:
 V <v pathlink.com> wrote:
 
 [...]
 
cannot implicitly convert expression (#buffer) of type WSABUF *
to WSABUF * 

You may want to check your source for multiple typedef's of `WSABUF'. -manfred

Apr 21 2005
parent reply V <v pathlink.com> writes:
Upon removing all LP types to type* and commented the alias', the 
problems disappear.

These alias' are bad, mmmkay:
alias WSAOVERLAPPED* LPWSAOVERLAPPED;
alias WSABUF* LPWSABUF;
alias void (* LPWSAOVERLAPPED_COMPLETION_ROUTINE)(in DWORD, in DWORD, in 
LPWSAOVERLAPPED, in DWORD);

So why is DMD choking on those aliased types?

Are these incorrect?  Thanks :-B



V wrote:
 After some searching I found this:
 
 alias WSABUF* LPWSABUF;
 
 I commented that out and changed all instances of LPWSABUF with WSABUF* 
 and magically that error disappeared, but the other 3 remain.
 
 :(
 :confused:
 
 
 
 Manfred Nowak wrote:
 
 V <v pathlink.com> wrote:

 [...]

 cannot implicitly convert expression (#buffer) of type WSABUF *
 to WSABUF * 

You may want to check your source for multiple typedef's of `WSABUF'. -manfred


Apr 21 2005
parent reply MicroWizard <MicroWizard_member pathlink.com> writes:
I understand your problems with weird type resolution in D,
maybe the time will make it cleaner... I hope...

But. Why do you use WSA... thing for sockets?
There is a solid socket (and socketstream) implementation in Phobos.

Tamas Nagy


In article <d49vvu$1j2l$1 digitaldaemon.com>, V says...
Upon removing all LP types to type* and commented the alias', the 
problems disappear.

These alias' are bad, mmmkay:
alias WSAOVERLAPPED* LPWSAOVERLAPPED;
alias WSABUF* LPWSABUF;
alias void (* LPWSAOVERLAPPED_COMPLETION_ROUTINE)(in DWORD, in DWORD, in 
LPWSAOVERLAPPED, in DWORD);

So why is DMD choking on those aliased types?

Are these incorrect?  Thanks :-B



V wrote:
 After some searching I found this:
 
 alias WSABUF* LPWSABUF;
 
 I commented that out and changed all instances of LPWSABUF with WSABUF* 
 and magically that error disappeared, but the other 3 remain.
 
 :(
 :confused:
 
 
 
 Manfred Nowak wrote:
 
 V <v pathlink.com> wrote:

 [...]

 cannot implicitly convert expression (#buffer) of type WSABUF *
 to WSABUF * 

You may want to check your source for multiple typedef's of `WSABUF'. -manfred



Apr 25 2005
parent jicman <jicman_member pathlink.com> writes:
In article <d4js5e$2uo7$1 digitaldaemon.com>, MicroWizard says...

But. Why do you use WSA... thing for sockets?
There is a solid socket (and socketstream) implementation in Phobos.

I agree. I've written a few applications using the Phobos socket libraries and they have worked perfectly. jic
Apr 28 2005
prev sibling parent V <v pathlink.com> writes:
After some searching I found this:

alias WSABUF* LPWSABUF;

I commented that out and changed all instances of LPWSABUF with WSABUF*
and magically that error disappeared, but the other 3 remain.

Thanks for the help!
:(
:confused:



Manfred Nowak wrote:
 V <v pathlink.com> wrote:
 
 [...]
 
cannot implicitly convert expression (#buffer) of type WSABUF *
to WSABUF * 

You may want to check your source for multiple typedef's of `WSABUF'. -manfred

Apr 21 2005
prev sibling parent reply Derek Parnell <derek psych.ward> writes:
On Thu, 21 Apr 2005 20:30:04 -0700, V wrote:

 I'm getting weird errors from the compiler about certain win32 types 
 that I have to declare like:
 
 alias void (* LPWSAOVERLAPPED_COMPLETION_ROUTINE)(in DWORD, in DWORD, in 
 LPWSAOVERLAPPED, in DWORD);
 
 Then import certain functions like:
 
 extern(Windows)
 {
 int WSASend(SOCKET s,
 	LPWSABUF,
 	DWORD,
 	LPDWORD,
 	DWORD,
 	LPWSAOVERLAPPED,
 	LPWSAOVERLAPPED_COMPLETION_ROUTINE);
 }
 
 And the error happens here:
 
 if (WSASend(client.socket, &buffer, 1, &sent, 0, &client.sendoverlapped, 
 &sendCompletion) && WSAGetLastError() != WSA_IO_PENDING)
 
 Errors:
 
 function network.WSASend (uint,WSABUF *,uint,uint*,uint,WSAOVERLAPPED 
 *,int(Windows *)(HANDLE,uint,uint,int)) does not match argument types 
 (uint,WSABUF *,int,uint*,int,WSAOVERLAPPED *,void(Windows *)(uint 
 dwError,uint cbTransferred,WSAOVERLAPPED *lpOverlapped,uint dwFlags))
 
 cannot implicitly convert expression (#buffer) of type WSABUF * to WSABUF *
 
 cannot implicitly convert expression (#*(client).sendoverlapped) of type 
 WSAOVERLAPPED * to WSAOVERLAPPED *
 
 cannot implicitly convert expression (#SendCompletion) of type 
 void(Windows *)(uint dwError,uint cbTransferred,WSAOVERLAPPED 
 *lpOverlapped,uint dwFlags) to void(Windows *)(uint,uint,WSAOVERLAPPED 
 *,uint)

In some ways, DMD is fairly simple minded. Your code fails because the literal '1' is believed by DMD to be an 'int', but the type DWORD is a 'uint', so DMD complains. If you change the call literal to '1U' all will be well again. Why DMD can't work out that if the literal as an int doesn't match, it can retry to match assuming that the literal is a uint, I haven't got a clue. -- Derek Melbourne, Australia 22/04/2005 2:07:34 PM
Apr 21 2005
next sibling parent V <v pathlink.com> writes:
I tried '1U' with no luck, all those errors still appear.
:(

Derek Parnell wrote:
 On Thu, 21 Apr 2005 20:30:04 -0700, V wrote:
 
 
I'm getting weird errors from the compiler about certain win32 types 
that I have to declare like:

alias void (* LPWSAOVERLAPPED_COMPLETION_ROUTINE)(in DWORD, in DWORD, in 
LPWSAOVERLAPPED, in DWORD);

Then import certain functions like:

extern(Windows)
{
int WSASend(SOCKET s,
	LPWSABUF,
	DWORD,
	LPDWORD,
	DWORD,
	LPWSAOVERLAPPED,
	LPWSAOVERLAPPED_COMPLETION_ROUTINE);
}

And the error happens here:

if (WSASend(client.socket, &buffer, 1, &sent, 0, &client.sendoverlapped, 
&sendCompletion) && WSAGetLastError() != WSA_IO_PENDING)

Errors:

function network.WSASend (uint,WSABUF *,uint,uint*,uint,WSAOVERLAPPED 
*,int(Windows *)(HANDLE,uint,uint,int)) does not match argument types 
(uint,WSABUF *,int,uint*,int,WSAOVERLAPPED *,void(Windows *)(uint 
dwError,uint cbTransferred,WSAOVERLAPPED *lpOverlapped,uint dwFlags))

cannot implicitly convert expression (#buffer) of type WSABUF * to WSABUF *

cannot implicitly convert expression (#*(client).sendoverlapped) of type 
WSAOVERLAPPED * to WSAOVERLAPPED *

cannot implicitly convert expression (#SendCompletion) of type 
void(Windows *)(uint dwError,uint cbTransferred,WSAOVERLAPPED 
*lpOverlapped,uint dwFlags) to void(Windows *)(uint,uint,WSAOVERLAPPED 
*,uint)

In some ways, DMD is fairly simple minded. Your code fails because the literal '1' is believed by DMD to be an 'int', but the type DWORD is a 'uint', so DMD complains. If you change the call literal to '1U' all will be well again. Why DMD can't work out that if the literal as an int doesn't match, it can retry to match assuming that the literal is a uint, I haven't got a clue.

Apr 21 2005
prev sibling parent V <v pathlink.com> writes:
Thanks for the help! :D
Apr 21 2005