18F2455 'Suspicious Pointer Conversion' Help

Hey guys. This past semester we learned to work with a dsPIC30F chip, so I decided to take up working on a project on an 18F2455, just cleaning up the code and fixing a couple bugs, and generally understanding the code better.

Here is the error Im getting (Im using MPLAB v8.43 and the LITE C18 compiler):
C:\Users\J Skoba\Desktop\Flasher GIT\picflash\XSPI.c:187:Warning [2054] suspicious pointer conversion

Here is the code causing the error. The line referenced in the error is the 'void XSPIWriteDWORD...' line:
Code:
void XSPIWriteDWORD(BYTE reg, DWORD data)
{
	XSPIWrite(reg, &data);
}
Here is XSPIWrite:

Code:
void XSPIWrite(BYTE reg, BYTE *data)
{
	PORTBbits.RB4 = 0; // SS	

	XSPIW((reg << 2) | 2);
	for (i = 0; i < 4; i++)
		XSPIW(*data++);
	
	PORTBbits.RB4 = 1; // SS	
}

and XSPIWriteDWORD is called here:
Code:
WORD XNANDErase(DWORD block)
{
...
	XSPIWriteDWORD(0x0C, block << 9);
...
}

Now the one thing we didnt cover were pointers (I think that may be covered in later semesters) so I dont quite understand what a suspicious pointer conversion is. Can anyone help me out?
 
Last edited:
You are passing an integer pointer to a routine which expects a char pointer. It's suspicious because it changes the size of the data it's pointing to. You can get rid of the error by doing XSPIWrite(reg, (unsigned char *) data); if you are sure that is what you want to do. I'm assuming data is defined as an int and not int*.

Mike.
 
It is a WARNING not an ERROR. Does the code work ?
You're absolutely correct - it is a warning and not an error. My mistake! Yes, the code does work as expected.


Excellent! I used (BYTE *) data instead of unsigned char but I checked the TypeDefs.h file and they are defined the same way (I didnt realize how they were defined [byte - char, dword - long], that would explain why I couldnt figure out the error). Thank you!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…