0

I am working on a program and am using Tiny C Compiler with SDL and OpenGL. TCC doesn't include headers for opengl, so I tried copying them from both Visual C++ and MinGW. Both of them fail to compile with the following error:

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

Line 1081 in both files is:

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 );

Expansion for 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

Expansion for APIENTRY:

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

The only compiler flags I am setting are -b, -g, -Wall, and a few include directories.

Can I have some assistance with this? I will be happy to provide more information if needed.

Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85
  • 4
    What does `GLAPI` and `APIENTRY` expand into after the C preprocessor is finished? – sarnold Oct 24 '11 at 22:53
  • 3
    and what are on lines 1080 and 1082? sometimes the error line number is propagated from a previous error. – dmh2000 Oct 24 '11 at 22:57
  • $0.02 says either contains `__declspec(dllimport)`. You can't just copy headers from other compilers and expect them to work. You're better off searching for a tiny C specific solution (or switching to another compiler). Or __stdcall. – user786653 Oct 24 '11 at 23:48
  • Do you know what the final expanded values are for `GLAPI` and `APIENTRY`? The value of `__WIN32__`, `WINGDIAPI`, `_MSC_VER`, and `__LCC__` are not obvious (although I'm guessing `_MSC_VER` is not being set by your compiler). – Ben Hocking Oct 25 '11 at 00:32

3 Answers3

3

To link with Windows system DLLs, TCC uses import definition files (.def) instead of libraries.

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.
1

I'm not really sure how I have fixed this. I think it had to do with some of the include directories I was passing. Anyway, problem is gone.

Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85
1

I had a similar sort of problem (expecting semicolon instead though). Try to #include <windows.h> before the OpenGL headers get imported; that seems to have fixed it for me.

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
Figs
  • 11
  • 1