Domanda

I've been wrapping a gl file for scheme and it failed twice in the gl.h header. I'm on OSx so it might be platform dependent, but I never seen this syntax anywhere else in my life.

typedef void (* glMultiDrawElementsProcPtr) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount);

Notice the const GLvoid* const *indices. The scheme C interpreter has a small C subset and doesn't understand this part of the header.

What does it mean and how can I safely replace it by something else... I changed it to

const GLvoid** indices

È stato utile?

Soluzione

Types in C and C++ are read from right to left except that most people insist in placing the const on the wrong side. Once you fixed the const placement from

const GLvoid* const*

to

GLvoid const* const*

it becomes trivial to read the type: It is a pointer to a const pointer to a const object of type GLvoid (you probably can't really have ovjects of type GLvoid but it's the placeholder for any object). You can also have the combinations where the inner pointer is modifiable and/or the object is modifiable depending on which const you leave out.

Altri suggerimenti

This means that indices is a pointer to a const GLvoid * const.

The datatype above can also be written as GLvoid const * const. This tells us that neither the data pointed to by the GLvoid* pointer, nor the pointer itself may be modified.

There is no such restriction on indices itself. You may modify the pointer to the GLvoid*.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top