Operating System - HP-UX
1753507 Members
5228 Online
108795 Solutions
New Discussion юеВ

Why -D_REENTRANT needed to compile applications

 
RW-S
Advisor

Why -D_REENTRANT needed to compile applications

Hi,
OS : HPUX 11iv3
Arch : IA64
Compiler : aCC: HP C/aC++ B3910B A.06.12 [Nov 03 2006]

Doubts :
1. Why do we need to have -D_REENTRANT symbol defined explicitly whenever we use reentrant functions like strtok_r.
Other compilers like the one on Solaris and AIX do not need the same.

Are there any specific advantages of having this symbol explicitly defined on the compile line?
3 REPLIES 3
Dennis Handly
Acclaimed Contributor

Re: Why -D_REENTRANT needed to compile applications

The correct option for multithreading is -mt.
If you aren't using threads, then you are stuck with -D_REENTRANT

RW-S
Advisor

Re: Why -D_REENTRANT needed to compile applications

Thanks.
I wanted to know is why does aCC need explicit symbol defined on the compile-line whereas the compilers on Solaris or AIX include this symbol by default?

Is it any performance related issue?
Dennis Handly
Acclaimed Contributor

Re: Why -D_REENTRANT needed to compile applications

>I wanted to know is why does aCC need explicit symbol defined on the compile-line

Because this is decided by various standardization issues and has nothing to do with the compiler.

>Is it any performance related issue?

I wouldn't think so. The _r forms put the burden on the user.