Alarm callbacks on Windows with Gnu or MinGW?

Brian Dessent brian@dessent.net
Wed Mar 7 23:37:00 GMT 2007


Dana Good wrote:

> Please excuse me if this is the wrong location for this post - I
> looked long and hard before I posted, and would be happy to be
> redirected!

You'd get better responses on the MinGW list.

> I am using C++ in Eclipse with CDT and MinGW on a Windows machine.
> I'd prefer not to use VC++.
> 
> I would like to implement a simple alarm callback, a la 'C', where I
> set a timer to go off and use a signal catcher to catch the
> interrupt/exception/signal/whatever.

For this you need to use the Win32 API.  See for example
CreateWaitableTimer(), SetWaitableTimer(), WaitForSingleObject(),
CreateThread/_beginthreadex and so on.  See MSDN for details, or the
platform SDK.

http://msdn2.microsoft.com/en-us/library/ms681924(VS.85).aspx
http://msdn2.microsoft.com/en-us/library/ms686967(VS.85).aspx
etc.

> My Googles have left me fairly convinced that I can't do this without
> including the VC++ libraries - is this true?

These are the APIs provided by the operating system; they have nothing
to do with Visual C++.  The w32api package includes all the import
libraries necessary to link against any of these Win32 API dlls.

Brian



More information about the Gcc-help mailing list