首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么出口(0)会给我带来错误?

为什么出口(0)会给我带来错误?
EN

Stack Overflow用户
提问于 2012-07-23 06:54:50
回答 4查看 16.3K关注 0票数 0

因此,我一直在遵循一个教程,当我试图编译以下代码时:

代码语言:javascript
复制
#include <glut.h>
#include <iostream>

void render(void);
void keyboard(unsigned char c, int x, int y);
void mouse(int button, int state, int x, int y);

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(100, 100);
    glutInitWindowSize(640, 480);
    glutCreateWindow("Test GLUT App");

    glutDisplayFunc(render); // render
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);

    glutMainLoop(); // initialization finished. start rendering
}

void render(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBegin(GL_TRIANGLES);
    glColor3f(0.5, 0.2, 0.9);
    glVertex2f(-0.5, -0.5);
    glColor3f(0.1, 0.2, 0.5);
    glVertex2f(0.0, -0.5);
    glColor3f(0.3, 0.9, 0.7);
    glVertex2f(0.0, 0.5);
    glEnd();

    glutSwapBuffers();  
}

void keyboard(unsigned char c, int x, int y)
{
    if(c == 27)
    {
        exit(0);
    }
}

void mouse(int button, int state, int x, int y)
{
    if(button == GLUT_RIGHT_BUTTON)
    {
        exit(0);
    }
}

我不知从哪里得到了3错误

错误1错误C2381:‘退出’:重新定义;__declspec(不返回)不同的c:\程序文件(x86)\microsoft 10.0\vc\include\stdlib.h 353

错误2错误C3861:“退出”:标识符未找到....main.cpp 45

错误3错误C3861:“退出”:标识符未找到....main.cpp 53

有人知道为什么会出现这个错误吗?我在使用VS2010。

EN

Stack Overflow用户

发布于 2013-11-26 03:33:37

您需要将标题声明为简单的工作,在我的comp中工作。

代码语言:javascript
复制
#include <stdlib.h>
#include <cstdlib>
#include <glut.h>
#include <iostream>
票数 0
EN
查看全部 4 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11607726

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档