Menu

void* pointer doesn't work in C++

ZeroG
2007-10-08
2013-04-29
  • ZeroG

    ZeroG - 2007-10-08

    I just downloaded bstrlib and started using it. It's great, but I have encountered one problem - I wanted to use the bstring type (intended for C) in C++, but when I compile the program, it gives me an error that it cannot convert from void* to bstring*. I received this error in Visual Studio 2005, but I tried it on my Linux box and got the same thing. I believe this is a difference between C and C++; that you always have to cast void* pointers in C++. I modified three lines in bstrlib.c (lines 2463, 2467, and 2488) to add (bstring*) before the calls to bstr__realloc, and it compiled and appears to work. I don't know much about the inner workings of bstrlib, and I'm not terribly experienced with C++ (even more so with C), so I guess my question is if I actually fixed a bug or if by casting like that I might create other problems. Thanks!

     
    • Paul Hsieh

      Paul Hsieh - 2007-10-11

      Indeed, you have found an oversight in the last update to Bstrlib.  This has been corrected in the CVS tree just as you suggested.  You can get this corrected version of bstrlib.c here:

      http://bstring.cvs.sourceforge.net/\*checkout*/bstring/tree/bstrlib.c?revision=1.181

      Thanks for pointing this out, I will try to update the distribution soon.

      --
      Paul

       
    • ZeroG

      ZeroG - 2007-10-16

      That works great - thanks!

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.