sciguy125
16-08-2005, 21:00
Are there any windows programmers around? I'm having some issues with CreateFile() from the win32 api. I'm compiling with MinGW and it's giving me the following error:
loader\serialio.cpp:192: error: cannot convert `const char*' to `const WCHAR*' for argument `1' to `void* CreateFileW(const WCHAR*, DWORD, DWORD, _SECURITY_ATTRIBUTES*, DWORD, DWORD, void*)'
here's the appropriate code:
port = CreateFile(dev.c_str(),GENERIC_READ|GENERIC_WRITE, 0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
dev is a std::string. I'm new to windows programming, so I might be missing something. All the documentation I can find, however, says that the first parameter should be a null terminated string. c_str() is supposed to give me that. I've also tried to use the following and I get an idential error:
port = CreateFile("COM1",GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,FILE _ATTRIBUTE_NORMAL,0);
Which leads me to believe that it's not that simple.
loader\serialio.cpp:192: error: cannot convert `const char*' to `const WCHAR*' for argument `1' to `void* CreateFileW(const WCHAR*, DWORD, DWORD, _SECURITY_ATTRIBUTES*, DWORD, DWORD, void*)'
here's the appropriate code:
port = CreateFile(dev.c_str(),GENERIC_READ|GENERIC_WRITE, 0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
dev is a std::string. I'm new to windows programming, so I might be missing something. All the documentation I can find, however, says that the first parameter should be a null terminated string. c_str() is supposed to give me that. I've also tried to use the following and I get an idential error:
port = CreateFile("COM1",GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,FILE _ATTRIBUTE_NORMAL,0);
Which leads me to believe that it's not that simple.