3

上記のエラーと他の約101個のエラー(合計102個のエラー)が発生します。私は周りを検索しましたが、見つけた唯一の解決策は、gl.hの前にwindows.hライブラリを含めることです。しかし、私はすでにそれをやっています。それで、解決策は何ですか?誰か助けてもらえますか?私はglutと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
4

5 に答える 5

7

これは通常、コンパイル設定またはコンパイル設定のWIN32_LEAN_AND_MEANいずれかでを定義することによって発生しstdafx.hます。

インクルードする前にそのマクロを定義するwindows.hと、使用頻度の低いヘッダーファイルと定義が自動的に除外されます。

OpenGLを使用しているため、使用頻度の低いヘッダーの一部を使用しているため、これをオフにする必要があります。

次のように、stdafx.hなどのヘッダーに表示される場合があります。

#define WIN32_LEAN_AND_MEAN

または、次のようなコンパイル設定にある可能性があります。

-DWIN32_LEAN_AND_MEAN
于 2012-10-31T16:07:23.430 に答える
5

windows.h直前に含めるのを忘れていますgl.hhttp://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>

私のために働きます。

また、プリコンパイル済みヘッダーを使用していないことを確認してください

于 2013-06-05T03:22:17.817 に答える
2

OK私は同じ問題を抱えていて、それを修正しました。プロジェクトに他のファイル(プリコンパイル済みヘッダー/.c/ .cpp)がないことを確認してください。それらを削除し、必要なファイルだけを残してください。

于 2013-10-07T06:01:19.480 に答える
2

SOILライブラリを使用しているようです。windows.hが含まれていることを確認してください(プリプロセッサは別のブランチを取る可能性があります)。SOILライブラリを変更しない場合は、WIN32が定義されていることを確認してください。そうでない場合は、_WIN32に置き換えることができます。

于 2014-10-01T03:58:11.130 に答える
0

これはすべてかなり間違っているようです(ごめんなさい!)。

これがwindows.hを含める必要があると大声で宣言しているからといって、windows.hを含める必要があるという意味ではありません。

OpenGLは、オープンスタンダードのプロトコルインターフェイス仕様です。したがって、関連するSTANDARDヘッダー(GL / gl.h、GL / glu.hなど)は、一部のプロプライエタリベンダーが思いついたプロプライエタリのがらくたで大規模な汚染を引き起こしてはなりません。

具体的には、以前は標準のGLヘッダーコンテンツに追加されたWin32固有のマクロWINGDIAPIとAPIENTRY(ヒント:そのヘッダーのSGIテキストを参照)について話しているため、これらのGLヘッダーは適切に自己完結型ではありません。そしてもう汎用インターフェース!! (つまり、1トンのwingdi.hやキッチンシンクなどが必要であり、この完全に環境固有のがらくた、windows.hなどでソースコードスコープ全体をグローバルに汚染するという大きな結果をもたらします)

したがって、この悲惨な状況を是正するには、次のように行う必要があります。

  1. これらのいくつかの必須だが欠落している(自己完結型ではないヘッダー!)環境固有の部分を提供するという最大限に正確な仕事をしようとする目的固有のローカルヘッダーを作成します。
  • APIENTRY定義ヘッダーファイル
  • WINGDIAPI定義ヘッダーファイル
  1. 関連する公式GLヘッダー(インターフェイス!)を含むすべての場所にこれらのヘルパーヘッダーを含めることによって、これらの不足している部分(自己完結型のOpenGLインターフェイスのために壊れています...)を提供します-Windows独自のプラットフォームのみ(#ifdef _WIN32)!
  2. Windows独自のOpenGLヘルパー(Win32 HDCなどを使用するヘルパー(wgl *()APIなど))を、適切に厳密に分離された独自の変換ユニット(.cpp)で処理するように細心の注意を払ってください。
  3. すべての標準/汎用/クロスプラットフォーム/ユニバーサルを保持します(読み取り:無実;-))OpenGL実装は、パーツを独自の翻訳単位に処理します(したがって、環境固有のwindows.hがらくたに完全に感染しないため、すべてで適切に機能しますプラットフォーム)
  4. 利益!(うまくいけば)

トピックに関連するリファレンス(すでに役立つ可能性があります):

github WindowsHModular

局所的に関連するもの:

  • Win32 min /maxマクロ「名前空間」/シンボル汚染(早期にNOMINMAXを定義し、必要に応じて__min / __maxを使用することをお勧めします)
  • Win32ニア/ファーマクロ

事実上外国のツールキットのごくわずかな部分(この場合はシンボルエクスポートマクロ)で標準のミニマリスト(?)インターフェイス(OpenGL)を汚染し、それによって十分に(ヘッダー側!)おそらく一般的なユーザーコードのグローバルスコープの汚染と、完全に環境固有のがらくた:windows.h(これらのパブリックインターフェイスヘッダーに、スコープ内で既に提供されている独自のコンパイラ固有のシンボルエクスポートマクロがあることを確認するだけではありません)。

tl; dr: "1つのプラットフォームが有効で、11のプラットフォームが壊れています-仕事は達成されました"

于 2019-11-11T15:47:34.437 に答える