Threading libsmbclient - a proposal.
Jeremy Allison
jra at samba.org
Wed Apr 8 00:44:23 GMT 2009
On Wed, Apr 08, 2009 at 12:41:23AM +0000, simo wrote:
>
> No, you have barriers in the include:
> #ifndef _smb_threads_h_
> #define _smb_threads_h_
>
> So multiple inclusion shouldn't really happen.
Multiple includes in the same module can't happen,
but inclusion in *different* modules can.
> I am trying to understand in which case this would make a difference.
Imagine we have module a.c which #define SMB_USE_THREADS
and includes smb_threads.h, and then module b.c which
also (by accident in an include header) also defines
SMB_USE_THREADS and includes smb_threads.h. In your
methed we get duplicate definitions of the sample
functions.
With the instantiation macro method you can
include "smb_threads.h" as many times as you
like but the implementation only gets defined
in the module where you have :
SMB_THREADS_DEF_PTHREAD_IMPLEMENTATION(var);
That's defined in a .c file, not in or before
a header, so it's much easier for a user of
the library to control and remember.
Jeremy.
More information about the samba-technical
mailing list