Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the _REENTRANT flag?

which compiling a multithreaded program we use gcc like below:

gcc -lpthread -D_REENTRANT -o someprogram someprogram.c 

what exactly is the flag -D_REENTRANT doing over here?

like image 932
Vijay Avatar asked Apr 08 '10 16:04

Vijay


1 Answers

Defining _REENTRANT causes the compiler to use thread safe (i.e. re-entrant) versions of several functions in the C library.

You can search your header files to see what happens when it's defined.

like image 117
JayM Avatar answered Oct 04 '22 11:10

JayM