public inbox for
 help / color / mirror / Atom feed
From: "Mark Weaver" <>
To: <>
Subject: RE: [pthreads-win32] How can you use errno with pthreads DLL?
Date: Wed, 19 Nov 2003 06:27:00 -0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

> I am trying to use pthreads-win32 but have run into a problem. I get an
> error return value from pthreads-win32 but I can't use the errno because
> pthreads-win32 uses the errno for its C runtime library but my app uses
> its own errno from its C runtime library. How do I read the errno from
> pthreads-win32's view of things inside its DLL? I don't see a function
> for such a thing. I looked at the pthread.dsp file and it is set to use
> "Multithreaded DLL" library mode, so I figure that pthreads-win32 is
> more or less forcing me to use that mode. Well my application doesn't
> use that and can't do so.
> So is it not possible for there to simply be a pthreads-win32 function
> to get the errno? It may not be highly pretty but as it stands right now
> pthreads-win32 is unusable because of this problem.
Well it seems to me that you have a few options here:

1. Recompile pthreads against the same runtime library that you are using
rather than MSVC.  This is more than likely the best solution as having two
different CRTs is nasty bloat: think two separate heaps and copies of all
support data structure, not to mention the additional code size.

2. Explicitly import and use the function "_errno" from MSVCRT.DLL.  To
avoid the linker going nuts with two copies of most of the standard C
library symbols the least painful way to do this is to use LoadLibrary and
GetProcAddress. _errno basically is a wrapper around some thread local
storage: errno needs to be per thread in a multi-threaded environment.

TBH, I thought that pthreads didn't really use errno but opted to return an
errno.h defined status code.  sem_* and sched_* do, so if you don't use
those you could bypass this problem.

  reply	other threads:[~2003-11-19  6:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-19  3:45 Pedriana, Paul
2003-11-19  6:27 ` Mark Weaver [this message]
2003-11-19 23:37 Pedriana, Paul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).