This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: error: 'PTHREAD_MUTEX_RECURSIVE' undeclared


On 10 Mar 2008, Metuki Sabhe said:

> On Mon, Mar 10, 2008 at 9:54 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>> On Mon, Mar 10, 2008 at 09:16:27PM +0200, Metuki Sabhe wrote:
>> > Can someone please shed some light here ?
>>
>> info libc 'Feature Test Macros'
>>
>> You need -D_GNU_SOURCE, -D_XOPEN_SOURCE=500 or -D_XOPEN_SOURCE=600
>> in this case.
>
> Thanks a million times !
>
> As an application developer who programmed many Linux applications,
> I was not aware that I need to do that !

It's in POSIX (well, _GNU_SOURCE isn't, but the others are). Every Unix
programmer should know POSIX (or at least refer to it, you'll have the
important bits off by heart fairly fast!)

> If I understand right from the libc manuals, I better use -D_GNU_SOURCE for
> every new Linux app I develop.

Only if you don't want it to be portable to non-Linux Unix systems.

I'd use

#define _POSIX_C_SOURCE 200112L

at the very top of each source file instead (or at the start of a header
consistently #included before all others), unless I had a very good
reason not to (such as needing GNU extensions).

(You shold probably use a #define for this, not a -D switch, because the
standard you're using is a property of the *code*, not of the build
environment.)

> I wonder.. did this affect me in any other way before ? or even more
> scary - If I begin to use it now, will it change the behavior of my
> programs ?

It will change the namespace shown to you.

-- 
`The rest is a tale of post and counter-post.' --- Ian Rawlings
                                                   describes USENET


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]