Casting to pointer reference?

M

Mrtn

Hi,

can anyone help me with understanding what is the purpose of ampersand sign
in following cast : (UNALIGNED DWORD*&) ? Below is code snipet where I
spoted this.

thanx

BOOL CWnd::ExecuteDlgInit(LPVOID lpResource)
{
BOOL bSuccess = TRUE;
if (lpResource != NULL)
{
UNALIGNED WORD* lpnRes = (WORD*)lpResource;
while (bSuccess && *lpnRes != 0)
{
WORD nIDC = *lpnRes++;
WORD nMsg = *lpnRes++;
DWORD dwLen = *((UNALIGNED DWORD*&)lpnRes)++; // *& -> ?????
//...
}
// ...
}
//...
}
 
B

Bob Hairgrove

DWORD dwLen = *((UNALIGNED DWORD*&)lpnRes)++; // *& -> ?????

I believe this is legal ... check section 5.2.10 "Reinterpret_cast",
paragraph 10 for more details.

Don't know exactly why it is used this way ... maybe to keep the
compiler from generating a copy of the pointer?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,122
Latest member
VinayKumarNevatia_
Top