Resolve C++ mode warnings about int vs size_t with gcc -Wconversion flag enabled.

https://github.com/nigels-com/glew/issues/6
This commit is contained in:
Nigel Stewart 2014-07-14 17:02:27 +10:00
parent 5f0a96150e
commit 4b78dc4b68
2 changed files with 6 additions and 4 deletions

View File

@ -6,6 +6,8 @@
# include <GL/glxew.h>
#endif
#include <stddef.h> /* For size_t */
/*
* Define glewGetContext and related helper macros.
*/

View File

@ -10,8 +10,8 @@ const GLubyte * GLEWAPIENTRY glewGetErrorString (GLenum error)
(const GLubyte*)"GLX 1.2 and up are not supported",
(const GLubyte*)"Unknown error"
};
const int max_error = sizeof(_glewErrorString)/sizeof(*_glewErrorString) - 1;
return _glewErrorString[(int)error > max_error ? max_error : (int)error];
const size_t max_error = sizeof(_glewErrorString)/sizeof(*_glewErrorString) - 1;
return _glewErrorString[(size_t)error > max_error ? max_error : (size_t)error];
}
const GLubyte * GLEWAPIENTRY glewGetString (GLenum name)
@ -24,8 +24,8 @@ const GLubyte * GLEWAPIENTRY glewGetString (GLenum name)
(const GLubyte*)"GLEW_VERSION_MINOR_STRING",
(const GLubyte*)"GLEW_VERSION_MICRO_STRING"
};
const int max_string = sizeof(_glewString)/sizeof(*_glewString) - 1;
return _glewString[(int)name > max_string ? 0 : (int)name];
const size_t max_string = sizeof(_glewString)/sizeof(*_glewString) - 1;
return _glewString[(size_t)name > max_string ? 0 : (size_t)name];
}
/* ------------------------------------------------------------------------ */