About Tessellation Object

I encountered a problem when I use the Tessellation Polygon to draw the concave polygon in c++. The compiler always tell me that there are some problems in the following

gluTessCallback(tobj, GLU_TESS_BEGIN, glBegin);
gluTessCallback(tobj, GLU_TESS_VERTEX, glVertex2fv);

The error messege is : ‘gluTessCallback’ : cannot convert parameter 3 from ‘void (unsigned int)’ to ‘void (__stdcall *)(void)’

I made the code in Visual c++. I found that when I compiled my code with *.c, there is no any problem, but when I change it to *.cpp, the compiler will told me the error message listed above. I don’t know why it works differently in the .c and .cpp. Anybody know that? How can I use the
tessellation object in c++? Thanks.

I don’t know if this is MSVC specific, or if it’s actually writtent in the C++ specifications (I think its written in the spec, not sure), but files ending with .c should be compiled as C code, while files ending with .cpp should be compiled as C++ code. C++ has a more strict type checking, and will complain more often than C when you try to convert form one type to another, witout explicitly typecasting it.

To get rid of the error, typecast the functioname to the type the compiler expect.

Try something like this.

gluTessCallback(tobj, GLU_TESS_BEGIN, reinterpret_cast<void (__stdcall *)()>(glBegin));