18

My code is full of warnings like

'glTranslatef' is deprecated: first deprecated in macOS 10.14 - OpenGL API deprecated. (Define GL_SILENCE_DEPRECATION to silence these warnings)

I did #define GL_SILENCE_DEPRECATION but that didn't fix the issue. I use freeglut that was installed by using brew install freeglut

Can I silence it somehow?

3
  • 1
    Where did you put the #define? You have to put it befor you include the header file. Commented Nov 30, 2018 at 17:47
  • @DietrichEpp it was right after the header. It's fixed now. Thanks!
    – Alexander
    Commented Nov 30, 2018 at 22:40
  • You should accept the answer that was given since you said it solved your problem. I realize this is an old post, but I just found it, and protocol is protocol
    – Duncan C
    Commented Apr 30, 2023 at 19:00

1 Answer 1

32

#define GL_SILENCE_DEPRECATION must go before OpenGL includes, so you can do something similar to this:

#ifdef __APPLE__
/* Defined before OpenGL and GLUT includes to avoid deprecation messages */
#define GL_SILENCE_DEPRECATION
#include <OpenGL/gl.h>
#include <GLUT/glut.h>
#else
#include <GL/gl.h>
#include <GL/glut.h>
#endif

Another way to workaround the issue is to pass the option -Wno-deprecated-declarations to the compiler during the compile phase.

1
  • 1
    Works as expected. Thanks. Commented Jan 10, 2022 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.