• Advertisement
Sign in to follow this  

conversion unsigned const char * to const char *

This topic is 4790 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to test to see if an extension is supported and I need to change a "unsigned const char *" into a "const char *" in C++ is this possible? I'm using it when I use the glGetString(GL_EXTENSIONS); function to test if Vertex Buffer Objects are supported. I tried using the tutorial for NeHe, but my program crashed at that function so I just left it out. Anybody else have any luck with any of my problems.....? thanks, JDev

Share this post


Link to post
Share on other sites
Advertisement
if (strstr(const_cast<const char *>(glGetString(GL_EXTENSIONS)),"ARB_vertex_buffer_object") != NULL)


d:\documents and settings\administrator\desktop\starfighter\jobjmodel.h(54) : error C2440: 'const_cast' : cannot convert from 'const unsigned char *' to 'const char *'

am I specifying it wrong......?
thanks,
JDev

Share this post


Link to post
Share on other sites
const_cast can only "turn on" or "turn off" the const modifier. You can't change the actual type.

For what you're trying to do, I would store the result of glGetString in a variable at whatever scope you need.


// ... lots of code here

const char *Extensions;

Extensions=reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));

// ... much more code here





But if you want to continue and do it your way, change const_cast to reinterpret_cast.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement