<p>If I have a <code>std::vector&lt;Foo&gt;</code> and want to store its size in a <code>GLuint</code>, my compiler gives a warning that there is possible loss of data.</p>

<pre><code>GLuint size = vec.size(); // "conversion from 'size_t' to 'GLuint', possible loss of data"
</code></pre>

<p>How do I correctly do this type of casting?
Are there more pitfalls of this kind with for example <code>float</code> to <code>GLfloat</code>?</p>

<opengl><c++><types>
Type conversion to GL-types
Dragonseel
# Type conversion to GL-types

(Asked by: username_0 on 2016-01-25)

If I have a std::vector and want to store its size in a GLuint, my compiler gives a warning that there is possible loss of data.
GLuint size = vec.size(); // "conversion from 'size_t' to 'GLuint', possible loss of data"

How do I correctly do this type of casting?
Are there more pitfalls of this kind with for example float to GLfloat?

**Tags:** opengl, c++, types

---

## 0 answers

