Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Two potential problem areas that might arise when compiling multithreaded code are header files and libraries. Header files might require adaptations for multithreading, and multithreaded versions of supporting libraries might need to be linked. In general, the compiler will make the correct decisions, but it is important to be aware of these issues by reading the documentation when encountering a new platform for the first time.
One example of how the included header files might change in the presence of multiple threads is the errno variable on Solaris. Solaris provides different implementations of this variable for single-threaded and multithreaded applications. In a single-threaded application, there is only one errno variable, so this can be an integer value. In a multithreaded application, an errno variable needs to be defined for each thread. The compiler flag -mt passes the compiler flag -D_REENTRANT, which makes the errno variable a multithread-aware macro.