bmx-ng / pub.mod

BlitzMax NG Pub modules port.
7 stars 8 forks source link

[freeaudio.mod] invalid conversion from ‘unsigned char*’ to ‘char*’ #46

Closed GWRon closed 3 years ago

GWRon commented 3 years ago
/BlitzMaxNG/mod/pub.mod/freeaudio.mod/pulseaudiodevice.cpp: In function ‘int InitPulse()’:
/BlitzMaxNG/mod/pub.mod/freeaudio.mod/pulseaudiodevice.cpp:47:30: error: invalid conversion from ‘unsigned char*’ to ‘char*’ [-fpermissive]
  char *p=bbStringToUTF8String( bbAppTitle );
          ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~

/BlitzMaxNG/mod/pub.mod/freeaudio.mod/pulseaudiodevice.cpp: In member function ‘virtual int pulseaudiodevice::reset()’:
/BlitzMaxNG/mod/pub.mod/freeaudio.mod/pulseaudiodevice.cpp:98:31: error: invalid conversion from ‘unsigned char*’ to ‘char*’ [-fpermissive]
   char *p=bbStringToUTF8String( bbAppTitle );
           ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~

Maybe a GCC-version thing?

GWRon commented 3 years ago

I assume this has to do with the ".cpp" file.

blitz_app.c:

void bbWriteStdout( BBString *t ){
    char *p=bbStringToUTF8String( t );
    fprintf( stdout,"%s",p );
    fflush( stdout );
    bbMemFree(p);
}

-> compiles fine

blitz_string.c defines it as this:

unsigned char *bbStringToUTF8String( BBString *str ){
    int len=str->length;
    size_t buflen = len * 4 + 1;
    unsigned char *buf=(unsigned char*)bbMemAlloc( buflen );
    return bbStringToUTF8StringBuffer(str, buf, &buflen);
}

So maybe it is something which became more "strict" (aka an error now) with newer GCCs ?

in brl.mod/volumes.mod/haikuglue.cpp this is done so too - so maybe in newer GCCs + Haiku, this might be an issue too:

BVolume * bmx_volumes_bvolume_new(BBString * name) {
    char * n = bbStringToUTF8String(name);
GWRon commented 3 years ago

Possibly a simple cast:

char *p=(char *)bbStringToUTF8String( bbAppTitle );

is all what is needed but ... maybe it should be written in a "c++" manner as suggested by some on stackoverflow. Am not sure about potential side effects (overflow).

char *p=reinterpret_cast<char*>( bbStringToUTF8String( bbAppTitle ) );