Subject: Re: _beginthread Problems with win95 and mingw32 using C++
From: [email-masked] (Colin Peters)

5 Dec 1997 07:08:21 -0800
Message-ID: <[email-masked]>
Reply-To: "Colin Peters" <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain;
	charset="US-ASCII"
Content-Transfer-Encoding: 7bit
To: "John Miller" <[email-masked]>
Cc: "GNU-Win32" <[email-masked]>

From: John Miller <[email-masked]>
To: [email-masked] <[email-masked]>
Date: Friday, December 05, 1997 2:25 PM
Subject: _beginthread Problems with win95 and mingw32 using C++
>I was able to solve the error below by
>commenting out the "__attribute__((__cdecl__))"  portion, but then when I
>attempt to use the _beginthread() finction I get an ld message that says
>"undefined reference to _beginthread(<ommeted>)"  ld fatal signal 1"
this also
>doesn't happen in "C".  Please help.

The reason the function doesn't work without __cdecl__ is that it is
getting name mangled like a C++ function (I think, see below). The header
file should feature a pair of sequences like this around the _beginthread
and other prototypes:

#ifdef __cplusplus
extern "C" {
#endif

.... function prototypes ...

#ifdef __cplusplus
}
#endif

The version of Mingw32 you are using might have a bug in that header. You
could try downloading version 0.1.4 from my web page, or the latest
snapshot if you feel brave (on second thought, if you download the latest
snapshot only pull out the process.h header file, the new specs won't work
with b18).

Now that it occurs to me, what does that prototype look like? It should be

unsigned long _beginthread (void (*pfuncStart)(void *), unsigned
unStackSize, void* pArgList);

It occurs to me that older versions of Mingw32 might have had an attempt
to cdecl pfuncStart, which is unnecessary and may cause problems in some
cases. Grab process.h out of 0.1.4 (I think) or the latest snapshot. Or
just replace the prototype with the one given above.

If none of this fixes things it might be a bug in the C++ parser (I doubt
it though). It works fine for me using Mumit Khan's Mingw32-native version
of EGCS. I can't test against b18 right now (since it isn't on my disk
drive).

Good luck,
Colin.

-- Colin Peters -- colin at fu.is.saga-u.ac.jp
-- Saga University Dept. of Information Science
-- http://www.fu.is.saga-u.ac.jp/~colin
-- http://www.geocities.com/Tokyo/Towers/6162

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".