GL include problems iOS

I have an existing huge source code base that partially uses JUCE. I have recently upgraded to JUCE 6 from JUCE 5 and my project builds fine for Android.
For iOS however, I have problems getting source files to compile that include something from the juce_opengl folder.

If I for instance put this line as the first line (as a test, I normally just include the JuceHeader.h) :
#include <JuceModules/juce_opengl/opengl/juce_gles2.h>

then I get a hit on:
#error gltypes.h included before juce_gles2.h

Which is funny, because it’s the first line in the .cpp file. If I create a project with the Projucer, then it builds fine. My own project is not built from the Projucer since it was already in existence before JUCE was there and I have no intention converting it into a Projucer project.
I have verified that the files inside JuceModules are equal between my project and the Projucer test project.

So that leaves a compiler setting that would include something for every file that would trigger _gltypes_h to get defined. Does anyone have a hint on this?

Are you able to right-click on the __gltypes_h_ preprocessor definition and find where it’s previously defined? Also, are you using precompiled headers? If so, is there a chance that your PCH includes the platform gltypes header?

No, right clicking and selecting ‘Jump to definition’ does not do anything. I searched the build settings for ‘pre’ and found ‘Precompile prefix header’ which was set to ‘Yes’. Turning it to ‘No’ didn’t make any difference.

Did you do a full rebuild after disabling the PCH?

Something else you could try is inspecting the preprocessor output for the .cpp file. This will at least tell you whether the gltypes.h header is actually being included somewhere, or whether the define is being added by the build system.

Yes, are rebuild didn’t help and once I add the include, Xcode is enable to generate the preprocessor content. I finally managed to delete the pch file and now a lot of other problems show up. I also use the Skia library, which also uses OpenGL and then I get things like:

No member named ‘glActiveTexture’ in namespace ‘juce::gl’, did you simply mean ‘glActiveTexture’? in juce_OpenGLExtensions.
If I then put the JUCE include first, I get:
Use of undeclared identifier “GL_TEXTURE_2D”; did you mean ‘juce::gl::GL_TEXTURE_2D’? in GLKEffectPropertyTexture (include by GLKit/GLKit.h). So, chicken and egg, what a mess!

Can you find a way to avoid including JUCE sources and Skia sources in the same translation unit?

No, since a part of the UI is made in Skia, and it pops up dialogs made in Juce etc.

Can you put a using namespace juce::gl somewhere before including the Skia headers, to make it use JUCE’s GL functions?

I ended up removing #include <juce_opengl/juce_opengl.h> from JuceHeader and only including it in the few classes that used it, so it seems to work now.
One more reason to get rid of Skia and porting that section to JUCE. :slight_smile: