This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]