delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/11/28/04:29:26

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <1F8B49DD9100D31195FC00A0C94989FE159623@obelix>
From: Joost Kraaijeveld <J DOT Kraaijeveld AT Askesis DOT nl>
To: "Cygwin AT Sourceware. Cygnus. Com (E-mail)"
<cygwin AT sourceware DOT cygnus DOT com>
Subject: Exception problems
Date: Tue, 28 Nov 2000 10:24:20 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)

Why does the program below crash if I run runFunction2()? Is it not possible
/ against standards to use exceptions in extern "C" functions?


Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
email: J DOT Kraaijeveld AT Askesis DOT nl
web: www.askesis.nl 

////////////////////////////////// Source
/////////////////////////////////////
#include <cstdio>
#include <windows.h>

extern "C" unsigned long WINAPI runFunction1(void* aAThreadFunction)
{
   for ( unsigned long i = 0;i<5;i++)
   {
      printf("%lu\n",i);
      Sleep(200);
   }
   return 0;
}

extern "C" unsigned long WINAPI runFunction2(void* aAThreadFunction)
{
   try
   {
      for ( unsigned long i = 0;i<5;i++)
      {
         printf("%lu\n",i);
         Sleep(200);
      }
   }
   catch(...)
   {
   }
   return 0;
}

int main(int argc, char* argv[])
{
   LPTHREAD_START_ROUTINE threadFunction;

   // any number and value of arguments will do to run runFunction2()
   if(argc == 1)
   {
      threadFunction = runFunction1;
   }else
   {
      threadFunction = runFunction2;
   }

   HANDLE threadHandles[2];
   unsigned long threadIds[2];

   // Create two threads
   threadHandles[0] = CreateThread(
NULL,0,threadFunction,NULL,0,&threadIds[0]);
   threadHandles[1] = CreateThread(
NULL,0,threadFunction,NULL,0,&threadIds[1]);

   // Wait for the threads to end
  WaitForMultipleObjects(2,&threadHandles[0],true,INFINITE);
}

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019