|
From: Jason H. <jas...@bt...> - 2001-11-07 17:00:24
|
The reason you get that problem is because you now have to cast a void pointer into the type you are using, and the old C style dynamic allocation functions will always return a void pointer as they have no way of determining the type of the value returned. i.e. char *currentObjName = static_cast<char*>(calloc(100, sizeof(char))); or if you are using C only you can use the old style cast: (char*) for C++... yes you can use strings, but you can also use the new and delete (or delete[]) operators. Strings are better for simplicity of use. Jason. ----- Original Message ----- From: "Gregor Peter" <pe...@in...> To: <dev...@li...> Sent: Wednesday, November 07, 2001 5:21 AM Subject: [Dev-C++] C vs C++ > My Compiler complains about the following codelines > > lineNo: c-code > 59: char *currentObjName = calloc( 100, sizeof( char ) ); > 60: char *token1 = calloc( 25, sizeof( char ) ); > 63: char *mltext, *ptext, *str; > 64: mltext = malloc( 10*sizeof(char)); > 318: mltext = realloc( mltext, (strlen(mltext)+yyleng)*sizeof(char) ); > 329: mltext = realloc( mltext, (strlen(mltext)+1)*sizeof(char) ); > > The compilers errmsg is: > > SCANNER.LEX:'lineNo': ANSI C++ forbids implicit conversion from > `void *' in initialization > > > Can tell me someone how to rewrite this ANSI C++ compatible? > > THANX > Gregor (pe...@in...) > > > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |