array incomplete type not allowed ?
May 20, 2017 at 11:03am May 20, 2017 at 11:03am UTC
so this code works fine:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
private :
GLuint vertexBufferID;
GLuint elementBufferID;
GLfloat verts[] =
{
0.0f, 1.0f,
-1.0f,-1.0f,
1.0f,-1.0f
};
public :
Drawable();
~Drawable();
void Draw();
but as soon as i add another array, i get an "incomplete type not allowed" error?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
private :
GLuint vertexBufferID;
GLuint elementBufferID;
GLushort elements[] =
{
0,1,2
};
GLfloat verts[] =
{
0.0f, 1.0f,
-1.0f,-1.0f,
1.0f,-1.0f
};
public :
Drawable();
~Drawable();
void Draw();
May 20, 2017 at 11:30am May 20, 2017 at 11:30am UTC
'
Flexible array member ' is a C99 feature (thre must be only one such member and it must be the last member of the struct).
https://en.wikipedia.org/wiki/Flexible_array_member
This is not allowed in standard C++.
http://coliru.stacked-crooked.com/a/29c6f202faaa628e
That your code compiled without errors when there was only one flexible array member is because the GNU/GNU-compatible compiler is by default not a conforming C++ compiler.
Specify the size of the arrays, and compile with a C++ compiler (specify these options):
g++ -std=c++14 -O3 -Wall -Wextra -pedantic-errors
Topic archived. No new replies allowed.