This is the mail archive of the cygwin-xfree mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: OpenGL-1.1.0 compile problem in cygwin-1.7


"Phan, Linh H" wrote:

> $ /usr/bin/g++ -g -c -I/usr/include/opengl test.c++
> x.c++: In function `void test()':
> x.c++:7: error: invalid conversion from `void (*)()' to `void (*)()'
> x.c++:7: error:   initializing argument 3 of `void gluTessCallback(GLUtesselator*, GLenum, void (*)())'
> x.c++:8: error: invalid conversion from `void (*)()' to `void (*)()'
> x.c++:8: error:   initializing argument 3 of `void gluTessCallback(GLUtesselator*, GLenum, void (*)())'
> x.c++:9: error: invalid conversion from `void (*)()' to `void (*)()'
> x.c++:9: error:   initializing argument 3 of `void gluTessCallback(GLUtesselator*, GLenum, void (*)())'

Here you are using the Win32 API version of these functions, and the
Win32 API generally uses the stdcall calling convention throughout,
including the callback.  C++ is very strict about types and it does not
consider "pointer to function taking no args and returning void using
cdecl calling convention" and "pointer to function taking no args and
returning void using stdcall calling convention" to be compatible
types.  It's just that the diagnostic doesn't display the calling
convention attribute of the type, so it only looks like they're the same
type from the message.

Moreover, the compiler is right to be picky because calling convention
is a fundamental aspect of the function -- it's not something that can
be fixed by just changing to the correct cast.  In this case since
glBegin et al. are also Win32 API functions they have the proper calling
convention, so you only need to fix the cast.  But if you were actually
implementing the callback in your code, you would have to both
explicitly ensure that it was is defined with the correct calling
convention, in addition to using the proper cast.

> But I can compile it if I use the /usr/X11R6/include/GL:
> 
> $ /usr/bin/g++ -g -c -I/usr/X11R6/include test.c++
> $

Here you're using the X11 version of the API, which uses the default
cdecl calling convention throughout.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]