Odd error building Paraview 5.11.1

Trying to build paraview on Rocky 9.5, with OSMesa installed we get the following odd errors:

In file included from /home/paraview/src/VTK/ThirdParty/glew/vtkglew/src/glew.c(41):                                                               
/usr/include/GL/osmesa.h(125): error: expected a ";"                                                     
  OSMesaCreateContext( GLenum format, OSMesaContext sharelist );                                         
  ^                                                                                                                                                                                                     
In file included from /home/paraview/src/VTK/ThirdParty/glew/vtkglew/src/glew.c(41):                                                               
/usr/include/GL/osmesa.h(138): error: expected a ";"                                                     
  OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,

In file included from /home/paraview/src/VTK/ThirdParty/glew/vtkglew/src/glew.c(41):                                                               
/usr/include/GL/osmesa.h(176): error: declaration is incompatible with "OSMesaContext APIENTRY" (declared at line 124)                                                                                           
  GLAPI void APIENTRY                                                                                    
             ^    

Any idea why is this happening?

Same error as this ?

Same error, no solution so far

Its also not related to VTK or ParaView ?

It happens compiling VTK/ThirdParty/glew/vtkglew/src/glew.c as part of the Paraview building process.

The error goes away when eliminating -DGLEW_OSMESAicc -diag-disable=10441,266 -DGLEW_NO_GLU # -DGLEW_OSMESA from the compilation command line.

APIENTRY is windows-specific, so my guess is that an #if/#ifdef in one of the GL headers is not correctly identifying the icc compiler and is incorrectly falling back on windows-specific settings.

that would make sense. Any ideas how to fix this?

Easiest fix would be to use gcc instead of icc.

I already suggested a fix on the VTK discourse thread that is linked above. Try giving GLAPIENTRY an empty definition. For good measure, you can try giving APIENTRY an empty definition, too.

The following VTK merge request looks related (see the end of the discussion for links to the suggested APIENTRY work-arounds for osmesa):
https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10980