Wierd warning
-
i recieved this warning : warning C4133: 'function' : incompatible types - from 'char [5]' to 'const unsigned short *' for the first line of the code below hCOM1 = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); I copied the code below from an older program, but i did not get that warning when i tried to compile it. Is there something i am doing wrong ?
-
i recieved this warning : warning C4133: 'function' : incompatible types - from 'char [5]' to 'const unsigned short *' for the first line of the code below hCOM1 = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); I copied the code below from an older program, but i did not get that warning when i tried to compile it. Is there something i am doing wrong ?
Definitely a problem with the "COM1" parameter. Possibly a Unicode problem? Don't have much experience with Unicode, sorry, but might try CreateFile(_T("COM1"), .... Someone else will know for sure... delete this; * poof! *
-
i recieved this warning : warning C4133: 'function' : incompatible types - from 'char [5]' to 'const unsigned short *' for the first line of the code below hCOM1 = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); I copied the code below from an older program, but i did not get that warning when i tried to compile it. Is there something i am doing wrong ?
-
i recieved this warning : warning C4133: 'function' : incompatible types - from 'char [5]' to 'const unsigned short *' for the first line of the code below hCOM1 = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); I copied the code below from an older program, but i did not get that warning when i tried to compile it. Is there something i am doing wrong ?
It's a Unicode issue. I'd wager the old project was ANSI but now it's Unicode. Try making the following change:
hCOM1 = CreateFile( _T("COM1"), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
Make sure you include
<tchar.h>
Steve -
i recieved this warning : warning C4133: 'function' : incompatible types - from 'char [5]' to 'const unsigned short *' for the first line of the code below hCOM1 = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); I copied the code below from an older program, but i did not get that warning when i tried to compile it. Is there something i am doing wrong ?
While it has nothing to do with warning C4133, that first argument will need to be changed to "\\\\.\\COM1" in order to open a serial port.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb