我一直有这个错误“错误1错误C2381:'退出':重新定义; declspec(noreturn)不同”每当我尝试编译以下代码时。我也尝试了在线解决方案,或者将过剩转移到最后,或者将stdlib.h移到顶部。但它仍然无法正常工作。 感谢您的帮助!我正在使用visual Studio 2012,cpp。
这是loop.cpp:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "loop.h"
const char g_szClassName[] = "myWindowClass";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"The title of my window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
**This is object.cpp:**
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <GL/glut.h>
#include "loop.h"
#include <windows.h>
HINSTANCE hInstance;
HINSTANCE hPrevInstance;
LPSTR lpCmdLine;
int nCmdShow;
HWND hwnd;
UINT msg;
WPARAM wParam;
LPARAM lParam;
void screen_keyboard(unsigned char key, int x, int y) {
char* name = 0;
Vertex* vertex;
long lines = 0;
switch (key) {
case 'W':
case 'w':
wire = !wire;
break;
case 'A':
case 'a':
refine(we);
unitize(we);
facetNormals(we);
printf("%d Faces.\n", faceCount(we));
break;
case 'S':
case 's':
subdivide(we);
unitize(we);
facetNormals(we);
printf("%d Faces.\n", faceCount(we));
break;
case 'L':
case 'l':
subdivide(we);
refine(we);
unitize(we);
facetNormals(we);
printf("%d Faces.\n", faceCount(we));
break;
case 'B':
case 'b':
subdivideButt(we);
refine(we);
unitize(we);
facetNormals(we);
break;
case 'D':
case 'd':
name = "data/drum.obj";
break;
case 'Z':
case 'z':
name = "data/ball.obj";
break;
case 'H':
case 'h':
name = "data/sphere.obj";
break;
case 'E':
case 'e':
name = "data/equilateraltri.obj";
break;
case 'U':
case 'u':
name = "data/cube.obj";
break;
case 'P':
case 'p':
name = "data/prism.obj";
break;
case 'C':
case 'c':
name = "data/cylinder.obj";
break;
case 'T':
case 't':
name = "data/isoscelestri.obj";
break;
case 'O':
case 'o':
name = filename;
break;
case 'I':
case 'i':
//Import shape
WinMain(hInstance, hPrevInstance,lpCmdLine, nCmdShow);
WndProc(hwnd, msg, wParam, lParam);
break;
case 'X':
case 'x':
lines = writeOBJ(we, "output.obj");
printf("Wrote output.obj (%d lines)\n", lines);
break;
case 'V':
case 'v':
verify(we);
break;
case '1':
vertex = we->vertices;
while (vertex) {
vertex->newpoint = GL_FALSE;
vertex = vertex->next;
}
firstDivision(we->faces);
unitize(we);
facetNormals(we);
printf("----- First Pass -----\n");
printf("%d Vertices.\n", vertexCount(we));
printf("%d Faces.\n\n", faceCount(we));
break;
case 'Q':
case 'q':
exit(1);
break;
case 'R':
case 'r':
break;
}
if (name) {
if (we) free(we);
we = readOBJ(name);
if (!we) exit(0);
unitize(we);
facetNormals(we);
}
redisplay_all();
}