This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin 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]

Saving rdbuf()


===========================================
Windows 2000
CYGWIN_NT-5.0 1.3.22(0.78/3/2)
GNU gcc version 3.2 20020927 (prerelease)
===========================================


====== C++ code : File t.cpp : BEGIN ======

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
streambuf* save_sbuf_cout;

// ---------------------------------------
// There is a design error in this program
// ------ Should be something like : -----
// ofstream log_file ("test.out");
//  save_sbuf_cout = cout.rdbuf();
//  cout.rdbuf(log_file.rdbuf());
// ---------------------------------------

  cout << "Hello-1" << endl;
  cout.rdbuf(save_sbuf_cout);
  cout << "Hello-2" << endl;

  return 0;
}

====== C++ code : File t.cpp : END ========


====== Compilation & Run : BEGIN ======

$ g++ t.cpp

$ a
Hello-1

====== Compilation & Run : END ========

No run error is generated.

Whereas MinGW (g++ 3.2) and DJGPP (g++ 3.2) do generate run error.

Why does 'CYGWIN behavior differ from MinGW and DJGPP in this case?

   =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
   =====================================





--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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