MinGW找不到C++ std :: vector.data

nsa*_*x91 1 c++ mingw

我已经能够使用以下C++代码使用OpenGL的glVertexPointer函数:

glVertexPointer(3, GL_DOUBLE, 0, myMeasuredPoints.data());
Run Code Online (Sandbox Code Playgroud)

myMeasuredPoints是一个C++向量,其元素类型为double.使用Visual C++编译此代码时,根本没有问题.但是,当使用MinGW进行编译时,我收到以下错误:

error: 'class std::vector<double, std::allocator<double>' has no member named 'data'
Run Code Online (Sandbox Code Playgroud)

Strangely, I do not get this error any other place in the code where I invoke functions such as myMeasuredPoints.push_back() to push values onto the vector. These other instances have all been before using the .data() function, so it hasn't simply been a case of the code crashing before reaching the other instances.

Any thoughts?

chr*_*ris 6

The data function was added in C++11. Make sure you compile with -std=c++0x or -std=c++11 and have a version of MinGW that includes the function.

If that's not possible, you can use the usual C++03 variant:

&myMeasuredPoints[0]
Run Code Online (Sandbox Code Playgroud)