I can't understand the following compile error:
unsigned char buf[1000];
const DWORD maxBytes = 1000;
OVERLAPPED o;
void foo(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped) {
return;
}
void bar(HANDLE hFile) {
auto lambda_foo = [](DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped){return;};
ReadFileEx(hFile, buf, 1000, &o, lambdafoo); //compiles
ReadFileEx(hFile, buf, 1000, &o, foo); //doesn't compile
}
Error is "cannot convert argument 5 from 'void (__cdecl *) DWORD,DWORD,LPOVERLAPPED)' to 'LPOVERLAPPED_COMPLETION_ROUTINE' ". I use MSVC2015.
Could somebody please tell me what I'am doing wrong? Why it compiles with lambda but not with identical free function?