_beginthread Problems with win95 and mingw32 using C++

Colin Peters colin@bird.fu.is.saga-u.ac.jp
Fri Dec 5 05:56:00 GMT 1997


From: John Miller <jfmiller@polymail.cpunix.calpoly.edu>
To: gnu-win32@cygnus.com <gnu-win32@cygnus.com>
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
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list