Glut in Dev C++ error “redeclaration of C++ built-in type `short'”

懵懂的女人 提交于 2019-12-02 03:06:01

Hard to say without seeing your exact glut.h and library versions, but I see roundabout line 45 of glut.h:

   /* XXX This is from Win32's <ctype.h> */
#  ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
#   define _WCHAR_T_DEFINED
#  endif

If wchar_t is already defined (to short for example), but the _WCHAR_T_DEFINED macro is not, the line will then be treated as:

typedef unsigned short short;

Which is a redeclaration of the built-in type. <iostream> (don't use the .h btw, it's not used anymore per standard) is adding defines such that the typedef is not executed, or undef'ing wchar_t if it is a macro such that the typedef is legal.

Joyhasan

I faced error redeclaration of c++ built-in type 'wchar_t' at the time of my car racing project. I searched in Google, but didn't find any solution to solve my problem :-(

But later, I solved this problem by including "windows.h" by myself :-)

#include<windows.h>
#include<bits/stdc++.h>
#include<GL/glut.h>

#include<windows.h> has to be added at the top. If it's added under glut.h there will be an error.

#include<bits/stdc++.h> just added for safety :-p

Use #include<GL/glut.h> or #include<glut.h> depending on the folder where glut.h has been placed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!