我收到上述错误以及大约101个错误(共102个错误)。我搜索过,我找到的唯一解决方案是在gl.h之前包含windows.h库。但我已经这样做了。那么解决方案是什么?谁能帮我?我正在使用过剩和opengl。以下是我的包含流程。如果您要求我提供更多代码,请告诉我
#include <stdio.h> // Standard C/C++ Input-Output
#include <math.h> // Math Functions
#include <windows.h> // Standard Header For MSWindows Applications
#include <GL/gl.h>
#include <time.h>
#include <stdlib.h>
#include "SOIL.h"
这是完整的错误列表:
Error 1 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1152
Error 2 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1152
Error 3 error C2146: syntax error : missing ',' before identifier 'glAccum' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1152
Error 4 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1152
Error 5 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1152
Error 6 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153
Error 7 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153
Error 8 error C2146: syntax error : missing ',' before identifier 'glAlphaFunc' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153
Error 9 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153
Error 10 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1153
Error 11 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1154
Error 12 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1154
Error 13 error C2146: syntax error : missing ',' before identifier 'glAreTexturesResident' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1154
Error 14 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1154
Error 15 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1154
Error 16 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1155
Error 17 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1155
Error 18 error C2146: syntax error : missing ',' before identifier 'glArrayElement' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1155
Error 19 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1155
Error 20 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1155
Error 21 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1156
Error 22 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1156
Error 23 error C2146: syntax error : missing ',' before identifier 'glBegin' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1156
Error 24 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1156
Error 25 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1156
Error 26 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1157
Error 27 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1157
Error 28 error C2146: syntax error : missing ',' before identifier 'glBindTexture' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1157
Error 29 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1157
Error 30 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1157
Error 31 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1158
Error 32 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1158
Error 33 error C2146: syntax error : missing ',' before identifier 'glBitmap' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1158
Error 34 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1158
Error 35 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1158
Error 36 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1159
Error 37 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1159
Error 38 error C2146: syntax error : missing ',' before identifier 'glBlendFunc' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1159
Error 39 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1159
Error 40 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1159
Error 41 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1160
Error 42 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1160
Error 43 error C2146: syntax error : missing ',' before identifier 'glCallList' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1160
Error 44 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1160
Error 45 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1160
Error 46 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1161
Error 47 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1161
Error 48 error C2146: syntax error : missing ',' before identifier 'glCallLists' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1161
Error 49 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1161
Error 50 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1161
Error 51 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1162
Error 52 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1162
Error 53 error C2146: syntax error : missing ',' before identifier 'glClear' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1162
Error 54 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1162
Error 55 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1162
Error 56 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1163
Error 57 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1163
Error 58 error C2146: syntax error : missing ',' before identifier 'glClearAccum' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1163
Error 59 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1163
Error 60 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1163
Error 61 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1164
Error 62 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1164
Error 63 error C2146: syntax error : missing ',' before identifier 'glClearColor' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1164
Error 64 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1164
Error 65 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1164
Error 66 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1165
Error 67 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1165
Error 68 error C2146: syntax error : missing ',' before identifier 'glClearDepth' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1165
Error 69 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1165
Error 70 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1165
Error 71 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1166
Error 72 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1166
Error 73 error C2146: syntax error : missing ',' before identifier 'glClearIndex' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1166
Error 74 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1166
Error 75 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1166
Error 76 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1167
Error 77 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1167
Error 78 error C2146: syntax error : missing ',' before identifier 'glClearStencil' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1167
Error 79 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1167
Error 80 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1167
Error 81 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1168
Error 82 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1168
Error 83 error C2146: syntax error : missing ',' before identifier 'glClipPlane' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1168
Error 84 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1168
Error 85 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1168
Error 86 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1169
Error 87 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1169
Error 88 error C2146: syntax error : missing ',' before identifier 'glColor3b' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1169
Error 89 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1169
Error 90 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1169
Error 91 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1170
Error 92 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1170
Error 93 error C2146: syntax error : missing ',' before identifier 'glColor3bv' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1170
Error 94 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1170
Error 95 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1170
Error 96 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1171
Error 97 error C2085: 'APIENTRY' : not in formal parameter list c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1171
Error 98 error C2146: syntax error : missing ',' before identifier 'glColor3d' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1171
Error 99 error C2143: syntax error : missing ';' before '(' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1171
Error 100 error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1171
Error 101 error C2054: expected '(' to follow 'WINGDIAPI' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1172
Error 102 error C1003: error count exceeds 100; stopping compilation c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 1172
答案 0 :(得分:5)
这通常是在WIN32_LEAN_AND_MEAN
或编译设置中定义stdafx.h
引起的。
在包含windows.h
之前定义该宏会自动排除不经常使用的头文件和定义。
由于您使用的是OpenGL,因此您需要使用其中一些不经常使用的标题,因此您需要将其关闭。
它可能出现在像stdafx.h这样的标题中,如下所示:
#define WIN32_LEAN_AND_MEAN
或者它可能在编译设置中如下:
-DWIN32_LEAN_AND_MEAN
答案 1 :(得分:2)
您忘记在windows.h
之前加入gl.h
。来自http://www.opengl.org/archives/resources/faq/technical/gettingstarted.htm:
Error: c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2054: expected '(' to follow 'WINGDIAPI' c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2085: 'APIENTRY' : not in formal parameter list
没有#include windows.h或在gl.h之后包含它。源文件 既不使用GLUT也不使用MFC,而是调用OpenGL,应该:
#include <windows.h> #include <GL/gl.h>
适合我。
另外,请确保您没有使用预编译的标题
答案 2 :(得分:2)
好的,我有同样的问题,我修复了它。只是确保你的项目中没有其他文件(预编译头文件/.c/ .cpp)。删除它们,只留下你需要的文件,它会起作用
答案 3 :(得分:2)
好像你正在使用SOIL库。确保包含windows.h(预处理器可能采用不同的分支)。如果您不想更改SOIL库,请确保已定义WIN32。如果没有,您可以用_WIN32替换它。
答案 4 :(得分:-1)
这一切似乎都是错误的人(对不起!)。
因为这大声地宣称 包括windows.h并不意味着 包括windows.h应该完成。
这仅仅是又一个臭名昭著的例子,黑手党以其良好的拥抱-延伸-扑灭恶作剧方式左右挥霍垃圾。
OpenGL是一个开放标准协议接口规范(尽管在Vista开发等过程中犯下了恶作剧,但请大声说清楚)。从而, 其相关的STANDARD标头(GL / gl.h,GL / glu.h等)应绝对不对 无论哪种专有废话,某些专有供应商都会设法解决。
具体地说,我说的是 Win32专用宏WINGDIAPI和APIENTRY,它们 已添加到 以前的标准GL标头内容(提示:请参见该标头中的SGI文本),以及 导致这些GL标头不再成为正确的自包含通用接口! (即,需要一整吨的wingdi.h和厨房水槽等,其后果是,使用这种完全基于环境的废话,windows.h等在全球范围内污染了整个源代码范围)
因此,要纠正这种可怕的情况,应该采取以下措施:
与主题相关的参考(可能已经有用)
与主题相关的内容: