char p = 0;
char* q = (char*)lpShareMemory;
do
{
p = getchar();
if (WaitForSingleObject(hClientReadOver, 5*1000) != WAIT_OBJECT_0)
goto SERVER_SHARE_MEMORY_END;
q[0] = p;
if (!ResetEvent(hClientReadOver)) goto SERVER_SHARE_MEMORY_END;//把指定的事件对象设置为无信号状态
if (!SetEvent(hServerWriteOver)) goto SERVER_SHARE_MEMORY_END;//把指定的事件对象设置为有信号状态
} while (p != "\n");
SERVER_SHARE_MEMORY_END: //错误指向这里
//释放共享内存
if (NULL != hServerWriteOver) CloseHandle(hServerWriteOver);
if (NULL != hClientReadOver) CloseHandle(hClientReadOver);
if (NULL != lpShareMemory) UnmapViewOfFile(lpShareMemory);
if (NULL != hFileMapping) CloseHandle(hFileMapping);
if (NULL != hMutex) ReleaseMutex(hMutex);
return 0;
错误提示本人看q的声明.本人看不出哪里有问题…
错误提示:initialization of “q” is skipped by “goto SERVER_SHARE_MEMORY_END”
: see declaration of “q”
解决方案
40
把本人声明在goto的前面
40
不是深层嵌套的话不必用goto
http://blog.csdn.net/hitlion2008/article/details/6844615
http://blog.csdn.net/hitlion2008/article/details/6844615