This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Help with _beginthread



> -----Original Message-----
> From: Bart Anderson [mailto:bartanderson@netscape.net]
> Sent: Saturday, May 15, 1999 9:10 AM
> To: cygwin
> Subject: Help with _beginthread
> 
> 
> ----------------------------------------------------
> Dear list
> 
> My main objective was to rip out MFC code from the infocom 
> interpreter.
> 
> I have struggled with this for a while now, and am in need of 
> technical
> help/suggestions.
> 
> My setup is egcs 1.1.2 with egcs-1_1_2-msvcrt40-runtime.zip installed
> I also have V 1.21 installed and working.
> 
> I have a test project that calls _beginthread() and this 
> compiles and works.
> I have a more complex project with the same call to 
> _beginthread(), but it
> can't find init_thread().
> 
> Any ideas. I'll only send the stuff people are willing to
> look at, I don't want to burden the list ...  ;)
> 
> ------------------------------------------
> in real project
> 
> WFrotzcmdw.cpp: _beginthread(init_thread(),4096,NULL);
> 
> ..\c\Win_init.c:void init_thread()
> 
> results from make
> g++ -c -I../include -o WFrotzapp.o WFrotzapp.cpp
> g++ -c -I../include -o WFrotzdlg.o WFrotzdlg.cpp
> g++ -c -I../include -o WFrotzmdlg.o WFrotzmdlg.cpp
> g++ -c -I../include -o WFrotzcnv.o WFrotzcnv.cpp
> g++ -c -I../include -o WFrotzcmdw.o WFrotzcmdw.cpp
> WFrotzcmdw.cpp: In function `BOOL startThread()':
> WFrotzcmdw.cpp:39: warning: implicit declaration of function `int
init_thread(...)'
> WFrotzcmdw.cpp:39: warning: passing `int' to argument 1 of
`_beginthread(void(*)(void *), unsigned int, void *)' lacks a cast

The germane point in this message is the call to _beginthread expects a
pointer to a function that returns void and accepts a single argument which
is a `pointer to void'.

You are not passing a pointer to a function in your call you are passing the
result of a function call (which is returning an `int') as the argument.
C++ is then trying to cast your int into a pointer to a function which is
wrong.

You should declare your function:

void init_thread( void*);

and call the function like so:

_beginthread( init_thread, 4096, NULL);

That should remove the error messages.

> g++ -c -I../include -o Thread.o Thread.cpp
> g++ -o WFrotz.exe  ./WFrotzapp.o ./WFrotzdlg.o ./WFrotzmdlg.o 
> ./WFrotzcnv
> .o
> ./WF
> rotzcmdw.o ./Thread.o  ../frotz/Alias.o ../frotz/Buffer.o 
> ../frotz/Fastme
> m.o
> ../
> frotz/Files.o ../frotz/Getopt.o ../frotz/Hotkey.o ../frotz/Input.o
> ../frotz/Math
> .o ../frotz/Object.o ../frotz/Other.o ../frotz/Process.o 
> ../frotz/Rando
> m.o
> ../fr
> otz/Redirect.o ../frotz/Screen.o ../frotz/Sound.o ../frotz/Stream.o
> ../frotz/Tab
> le.o ../frotz/Text.o ../frotz/Variable.o ../frotz/Main.o  
> ../c/Win_init.o
> 
> ../c/W
> in_input.o ../c/Win_pic.o ../c/Win_scrn.o ../c/Win_smpl.o 
> ../c/Win_text.o
> -lV
> -W
> l --subsystem,windows -lgdi32 -luser32 -lwinmm -lcomdlg32 -lcomctl32
> ./WFrotzcmdw.o(.text+0x18):WFrotzcmdw.cc: undefined reference 
> to `init_
> thread'
> C:\EGCS-1~1.2\BIN\MAKE.EXE: *** [WFrotz.exe] Error 1
> 
> ----------------------------------------------------------
> in test project
> cfunc.c:void init_thread()
> main.cpp:       _beginthread(init_thread(),4096,NULL);
> 
> results of make
> C:\WinFrotz\Vproj\test>make
> g++ -c main.cpp
> main.cpp: In function `int main()':
> main.cpp:18: warning: implicit declaration of function `int 
> init_thread(.
> ..)'
> main.cpp:18: warning: passing `int' to argument 1 of 
> `_beginthread(void
> (*)(void
>  *), unsigned int, void *)' lacks a cast
> gcc -c cfunc.c
> g++ -o main.exe  ./main.o ./cfunc.o  -lv -Wl 
> --subsystem,windows -lcomctl
> 32
> -lus
> er32 -lgdi32 -lwinmm -lcomdlg32
> gcc -c cmain.c
> gcc -o cmain cmain.o cfunc.o
> 
> ____________________________________________________________________
> Get your own FREE, personal Netscape WebMail account today at
http://webmail.netscape.com.


W. Terry Lincoln                         \     \   _   /
Senior Engineer                           \     \ |J| /
Ultimate Technology Corporation            \     _|E|_
a Tridex Company (NASDAQ:trdx)              \   |_ S _|
mailto:WTerryLincoln@engineer.com            \    |U|
http://www.AngelFire.com/ny/TerryLincoln      \ / |S| \
http://www.geocities.com/Eureka/concourse/7326 \  | |
================================================ ~~~~~
Opinions expressed do not represent the management of UTC.


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]