Re: reentrant library functions
- From: Mike <michael.h.williamson@xxxxxxxxx>
- Date: Thu, 18 Sep 2008 16:24:56 -0700 (PDT)
On Sep 18, 9:20 pm, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:
On Sep 17, 1:29 pm, Mike <michael.h.william...@xxxxxxxxx> wrote:
On Sep 16, 10:01 pm, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:
Hi, I am trying to create a library of some functions that allow
reentrancy, but I don't want to require compiling with the thread
library, "-lpthread", for programs that use my functions, but that
don't use threads. How do I do that?
Here you say you don't want to require *compiling* with the thread
First, to correct one error in your post, '-lpthread' is a linker flagI do not quite understand.
and has no effect on compiling. You probably mean '-pthread', which on
many platforms (including Linux), selects compiling and linking for
My functions use semaphores to ensure that any threaded access
is exclusive (sem_wait() and sem_post()). I need the '-lpthread' flag,
or else I get linker errors.
If you were able to get linker errors, that means you had something to
link. That means that the compiling worked. So you *don't* need to
specify the '-lpthread' flag to compile. If you did, you would never
get linker errors because you'd have nothing to link.
You are using a platform that doesn't require any special compiler
flags to make thread-safe code. However, it's still good practice to
specify '-pthread' just in case. On Linux, this has no effect on
compilation and only affects linking.
I think I understand. I should have asked: For a program that uses
my functions, but not threads, is there a way it can be linked
having to state '-lpthread'.
(And, I do define _REENTRANT for compiling my functions.)
- Prev by Date: Re: reentrant library functions
- Next by Date: Re: reentrant library functions
- Previous by thread: Re: reentrant library functions
- Next by thread: Re: reentrant library functions