casting - C++ mixing pointers to different char types -
i writing program in c++ takes act (adobe color table) file , converts plain-text readable jasc-pal file. want read binary data act file , store in memory use. wrote following code , builds using bcc55. problem build warning: "warning w8079 : mixing pointers different 'char' types in function read_file()".
unsigned char * memblock; bool read_file() { int filesize; ifstream act ("test.act", ios::binary|ios::ate); if (act.is_open()) { filesize = act.tellg(); act.seekg(0); memblock = new unsigned char [filesize]; act.read(memblock, filesize); act.close(); cout << "color table loaded memory." << endl; return true; } else { cout << "failed open file." << endl; return false; } }
looking warning @ embarcadero documentation wiki seems because passing unsigned char pointer function expecting regular char pointer. says technically incorrect harmless. question if is, strictly speaking, incorrect how go doing without causing w8079 warning @ build time? should bother since warning harmless , code works expected?
add cast. in case use simple c cast.
act.read((char*)memblock, filesize);
but use reinterpret_cast well
act.read(reinterpret_cast<char*>(memblock), filesize);
but makes seem bigger deal is. documentation says, harmless.
Comments
Post a Comment