From: Nic on 1 Feb 2010 00:02 Hello how can I convert from UINT_PTR to LPVOID? Thanks. Nic
From: Igor Tandetnik on 1 Feb 2010 00:29 Nic wrote: > how can I convert from UINT_PTR to LPVOID? UINT_PTR n = 42; LPVOID p = reinterpret_cast<LPVOID>(n); -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
From: Nic on 1 Feb 2010 00:59 "Igor Tandetnik" <itandetnik(a)mvps.org> wrote in message news:OIKKA%23voKHA.5508(a)TK2MSFTNGP02.phx.gbl... Nic wrote: > how can I convert from UINT_PTR to LPVOID? UINT_PTR n = 42; LPVOID p = reinterpret_cast<LPVOID>(n); -- With best wishes, Igor Tandetnik Many thanks. This has fixed the problem though I'm not sure why I can't just do LPVOID(n)? Nic.
From: David Wilkinson on 1 Feb 2010 05:25 Nic wrote: > UINT_PTR n = 42; > LPVOID p = reinterpret_cast<LPVOID>(n); > > Many thanks. This has fixed the problem though I'm not sure why I can't just > do LPVOID(n)? Because UINT_PTR is not a pointer. It is an unsigned integer type with the same size as a pointer. So you have to do an explicit cast. -- David Wilkinson Visual C++ MVP
From: Igor Tandetnik on 1 Feb 2010 07:37 Nic wrote: > "Igor Tandetnik" <itandetnik(a)mvps.org> wrote in message > news:OIKKA%23voKHA.5508(a)TK2MSFTNGP02.phx.gbl... > Nic wrote: >> how can I convert from UINT_PTR to LPVOID? > > UINT_PTR n = 42; > LPVOID p = reinterpret_cast<LPVOID>(n); > > Many thanks. This has fixed the problem though I'm not sure why I can't just > do LPVOID(n)? You can. Personally, I prefer the notation using type conversion operator, but a functional cast ( LPVOID(n) ) or a C-style cast ( (LPVOID)n ) should both work, too. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
|
Next
|
Last
Pages: 1 2 Prev: enum operator overloading VC9 compiler bug? Next: Rectangular objects from client area |