IOStream does not provide write(void *, unsigned int) method

Jose Santiago santiago@haulpak.com
Wed Jan 2 07:04:00 GMT 2002


The following simple program compiles and runs under g++ 2.X, but does not 
under 3.X. I would image that there should be a ostream.write(void *, 
unsigned int) method that would match the call in this program.

   #include <sys/types.h>
   #include <stdint.h>
   #include <iostream.h>
   #include <fstream.h>
   int main(void)
   {
     unsigned int auint = 33;
     uint8_t buffer[sizeof(unsigned int)];
     ofstream outfile("outfile");
     if (!outfile.good())
     {
       cerr << "Error Opening Output File.\n";
       return 1;
     }
     memcpy(buffer,&auint,sizeof(unsigned int));
     outfile.write(buffer,sizeof(unsigned int));
     outfile.close();
     return 0;
   }

The error message during compilation is:

main.cpp: In function 'int main()':
main.cpp:17: no matching function call to 'std::basic_ofstream<char,
    std::char_traits<char> >::write(unsigned char[4], unsigned int)'
/appl/gcc/include/g++-v3/bits/ostream.tcc:370: condidates are:
    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
     _Traits>::write(const _CharT*, int) [with _CharT = char, _Traits =
     std::char_traits<char>]

-- 
Jose Santiago



More information about the Gcc-bugs mailing list