Silencing OpenGL warnings on macOS Mojave

11,107

You should put #define GL_SILENCE_DEPRECATION before the 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.

Share:
11,107

Related videos on Youtube

Alexander
Author by

Alexander

Updated on June 23, 2022

Comments

  • Alexander
    Alexander almost 2 years

    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?

    • Dietrich Epp
      Dietrich Epp over 5 years
      Where did you put the #define? You have to put it befor you include the header file.
  • Fahim Rahman
    Fahim Rahman over 2 years
    Works as expected. Thanks.