# Warnings?

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a question about warnings. I know some warnings are worse than others, but I cannot seem to fix a few of them. I was wondering if all warnings are bad necessarily, or if they are acceptible so to speak. Here is a list of warnings I have now that I haven't figured out how to fix, and the code that causes them:
//warning C4311: 'reinterpret_cast' : pointer truncation from 'LPVOID' to 'long'
SetWindowLongPtr(hWnd, GWL_USERDATA, reinterpret_cast<long>((LPCREATESTRUCT(lParam)->lpCreateParams)));

//warning C4311: 'type cast' : pointer truncation from 'HICON' to 'LONG'
HICON tempIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(m_Icon));
SetClassLongPtr(m_hWnd, GCL_HICONSM, (LONG)tempIcon);
SetClassLongPtr(m_hWnd, GCL_HICON, (LONG)tempIcon);

//warning C4311: 'type cast' : pointer truncation from 'MCI_STATUS_PARMS *__w64 ' to 'DWORD'
MCI_STATUS_PARMS m_StatusParams;
mciSendCommand(m_OpenParams.wDeviceID, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, (DWORD)&m_StatusParams)

//warning C4312: 'reinterpret_cast' : conversion from 'LONG' to 'Window *' of greater size
return reinterpret_cast<Window*>(GetWindowLongPtr(hWnd, GWL_USERDATA));

//warning C4312: 'type cast' : conversion from 'MCIDEVICEID' to 'LPSTR' of greater size
m_OpenParams.lpstrDeviceType  = (LPSTR)MCI_ALL_DEVICE_ID;

//warning C4312: 'type cast' : conversion from 'unsigned int' to 'char *' of greater size
//I was having a problem with some pointers that would return one of the
//following values.  checking them against NULL did not appear to work.
//When I used a breakpoint and moused over the pointer variable it would
//say <BadPtr> and one of the following values, this was the easiest way
//I could think of to check the variable before getting errors.
{
if(ptr == (char*)0x00000000 || ptr == (char*)0xffffffff)
return true;
else
return false;
}


If anyone has any idea if the warnings are bad or not (for lack of better words) I would be happy to learn which ones definately need fixed, and if possible a way to go about fixing them. Thanks in advance.

##### Share on other sites
You have 64-bit compatibility mode warnings turned on, that is giving you these messages. You can ignore them if you're not interested in porting your program to 64-bit. Better yet, you turn them off, as I'm sure someone will explain shortly.

##### Share on other sites
Thank you iMalc. It seems I read somewhere how to turn them off a long time ago, I will try to remember how, I think it is in the project settings somewhere.

EDIT:
I found it.

Right click Project->Properties->C/C++-> General->Detect 64-Bit Portability Issues

I turned it to NO and I no longer get any of the errors. I guess they were all only for 64 bit portability.

Thank you again.

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633674
• Total Posts
3013277
×