Sun Studio 12 Update 1: C++ User's Guide

A.2.91 -sync_stdio=[yes|no]

Use this option when your run-time performance is degraded due to the synchronization between C++ iostreams and C stdio. Synchronization is needed only when you use iostreams to write to cout and stdio to write to stdout in the same program. The C++ standard requires synchronization so the C++ compiler turns it on by default. However, application performance is often much better without synchronization. If your program does not write to both cout and stdout, you can use the option -sync_stdio=no to turn off synchronization.

A.2.91.1 Defaults:

If you do not specify -sync_stdio, the compiler sets it to -sync_stdio=yes.

Examples:

Consider the following example:


#include <stdio.h>
#include <iostream>
int main()
{
   std::cout << "Hello ";
   printf("beautiful ");
   std::cout << "world!";
   printf("\n");
}

With synchronization, the program prints on a line by itself


Hello beautiful world!
:

Without synchronization, the output gets scrambled.

Warnings:

This option is only effective for linking of executables, not for libraries.