2011-10-24 34 views
0

我正在開發一個程序,並且正在使用帶有SDL和OpenGL的Tiny C編譯器。 TCC不包含opengl頭文件,所以我試着從Visual C++和MinGW中複製它們。他們都失敗,出現以下錯誤編譯:1081OpenGL + Tiny C編譯器:「,expected」

v:/exe/tcc/include//GL/gl.h:1081: ',' expected

線在這兩個文件是:

GLAPI void APIENTRY glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w); 
GLAPI void APIENTRY glVertex2dv(const GLdouble *v); // <-- line 1081 
GLAPI void APIENTRY glVertex2fv(const GLfloat *v); 

擴展爲GLAPI:

/* GLAPI, part 1 (use WINGDIAPI, if defined) */ 
#if defined(__WIN32__) && defined(WINGDIAPI) 
# define GLAPI WINGDIAPI 
#endif 

/* GLAPI, part 2 */ 
#if !defined(GLAPI) 
# if defined(_MSC_VER)      /* Microsoft Visual C++ */ 
# define GLAPI __declspec(dllimport) 
# elif defined(__LCC__) && defined(__WIN32__) /* LCC-Win32 */ 
# define GLAPI __stdcall 
# else          /* Others (e.g. MinGW, Cygwin, non-win32) */ 
# define GLAPI extern 
# endif 
#endif 

擴展爲APIENTRY:

/* APIENTRY */ 
#if !defined(APIENTRY) 
# if defined(__WIN32__) 
# define APIENTRY __stdcall 
# else 
# define APIENTRY 
# endif 
#endif 

我設置的唯一編譯器標誌是-b,-g,-Wall和一些包含目錄。

我可以幫忙嗎?如果需要,我會很樂意提供更多信息。

+4

C預處理器完成後,GLAPI和APIENTRY會展開成什麼樣子? – sarnold

+3

以及1080和1082行是什麼?有時錯誤行號會從先前的錯誤中傳播。 – dmh2000

+0

$ 0.02表示包含'__declspec(dllimport)'。你不能只複製其他編譯器的頭文件,並期望它們工作。你最好尋找一個微小的C特定解決方案(或切換到另一個編譯器)。或者__stdcall。 – user786653

回答

1

我不太確定我是如何解決這個問題的。我認爲這與我傳遞的一些包含目錄有關。無論如何,問題已經消失。

1

我有一個類似的問題(雖然期待分號)。在導入OpenGL標頭之前嘗試#include <windows.h>;這似乎已經解決了我的問題。

3

要與Windows系統DLL鏈接,TCC使用導入定義 文件(.def)而不是庫。

The included 'tiny_impdef' program may be used to make additional 
.def files for any DLL. For example: 

    tiny_impdef.exe opengl32.dll 

Put opengl32.def into the tcc/lib directory. Specify -lopengl32 at 
the TCC commandline to link a program that uses opengl32.dll.