Thread overview
Compiler not recognizing certain structs, types?
Apr 22, 2005
V
Apr 22, 2005
Manfred Nowak
Apr 22, 2005
V
Apr 22, 2005
V
Apr 25, 2005
MicroWizard
Apr 28, 2005
jicman
Apr 22, 2005
V
Apr 22, 2005
Derek Parnell
Apr 22, 2005
V
Apr 22, 2005
V
April 22, 2005
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)
April 22, 2005
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
April 22, 2005
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
April 22, 2005
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.
> 
April 22, 2005
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
April 22, 2005
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
April 22, 2005
Thanks for the help! :D
April 22, 2005
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
April 25, 2005
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


April 28, 2005
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