Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am using Visual C++ 2010 and I get the following errors:

1>d:\visual c++\vc\include\stdlib.h(353): error C2381: 'exit' : redefinition; __declspec(noreturn) differs
1>d:\glut-3.7.6-bin\include\gl\glut.h(146) : see declaration of 'exit'

In my project I have 3 files. Here are the includes from each of them.

Main.cpp

#include<iostream>
#include "BmpLoader.h"
#include<glut.h>

BmpLoader.h

#include<stdio.h>
#include<glut.h>
#include<Windows.h>

BmpLoader.cpp

#include "BmpLoader.h"

As far as I know, I receive this error due to the include order. I have tried so far several arrangements of the includes, but haven't figured out the proper arrangement.

What library combination causes this error and what include order should I use in order to prevent it?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

The problem is that glut.h defines a new exit() function, which overrides the one in stdlib.h (included by Windows.h). This problem has also been addressed on Stack Overflow here.

The solution is to include Windows.h before glut.h.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.