Error: functions that differ only in the return type cannot be overloaded

I am using mac os 10.9, I have a C ++ program that uses the freeglut library. When I try to make a project. This gives an error that I don’t know whether it is my fault or not. This post is:

In file included from /usr/X11/include/GL/freeglut.h:18: /usr/X11/include/GL/freeglut_ext.h:177:27: error: functions that differ only in their return type cannot be overloaded FGAPI GLUTproc FGAPIENTRY glutGetProcAddress( const char *procName ); 

Additional information: I used cmake (version 2.8.12) to create a Makefile, installed the latest version of Xcode and XQuartz.
Any help is appreciated. Thanks.


In the files glut.h and freeglut_ext.h:
In glut.h:

 #if (GLUT_API_VERSION >= 5) extern void * APIENTRY glutGetProcAddress(const char *procName) OPENGL_DEPRECATED(10_3, 10_9); #endif 

In freeglut_ext.h:

 /* * Extension functions, see freeglut_ext.c */ typedef void (*GLUTproc)(); FGAPI GLUTproc FGAPIENTRY glutGetProcAddress( const char *procName ); 
+6
source share
1 answer

One declaration returns the type of the GLUTproc function (indicating a function that takes no arguments), and the other declaration returns a pointer ( void* ). Both functions accept the same arguments (one const char* ). What the compiler says is true.

You only see the complaint about "overload" because it is C ++. In C ++, if the compiler believes that it sees two different functions with the same name, each of them must have different arguments (for example, a different number of arguments or different types).

In this case, I doubt that the functions should be different; they must be the same, and at some point the API evolved and changed the declaration.

You need to find a way to prevent both ads from displaying at the same time (perhaps by setting GLUT_API_VERSION ). If you need, you can #include only one of the files and see if you really need another file (and if you did, you may have to manually declare some things to avoid the second #include ).

+5
source

Source: https://habr.com/ru/post/958221/


All Articles