pthreads, printf and cout

Alex Vinokur alexvn@connect.to
Fri Jan 2 17:57:00 GMT 2004


Hi,
Behavior of printf and cout in a program below is different : cout prints nothing.
What is wrong?
===================================
Windows 2000 Professional
CYGWIN_NT-5.0 1.5.4(0.94/3/2)
gcc version 3.3.1 (cygming special)
===================================
====== C++ code : foo.cpp : BEGIN ======
#include <stdio.h>
#include <iostream>
#include <pthread.h>
#include <unistd.h>
using namespace std;
extern "C" void* Run(void *)
{
 printf ("printf : Run Start\n");
 cout << "cout : Run Start" << endl;
 sleep (3);
 printf ("printf : Run Finish\n");
 cout << "cout : Run Finish" << endl;
}
int main ()
{
pthread_t t1;
 pthread_create(&t1, NULL, Run, NULL);
int errNum = pthread_join(t1, NULL);
 printf ("printf : errNum = %d\n", errNum);
 cout << "cout : errNum = " << errNum << endl;
}
====== C++ code : foo.cpp : END ========
====== Compilation & Run : BEGIN ======
$ g++ foo.cpp
$ a
printf : Run Start
printf : Run Finish
printf : errNum = 0
// cout prints nothing
====== Compilation & Run : END ========
--
 =====================================
 Alex Vinokur
 mailto:alexvn@connect.to
 http://mathforum.org/library/view/10978.html
 news://news.gmane.org/gmane.comp.lang.c++.perfometer
 =====================================
--
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/


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /