This is the mail archive of the cygwin-developers@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: (patch) makethread stdcall/cdecl confusion


On Thu, Sep 16, 1999 at 10:29:50AM -0500, Mumit Khan wrote:
>Another issue when you're dealing with thread start routines -- it's 
>almost always better to malloc the the parameter argument instead of
>passing the address of a stack data element. It'll work in the current
>usages in winsup, but this usage can lead to very subtle and hard to
>track errors. 

That's probably because, AFAICT, in every case where the argument is
non-NULL it *is* malloced.

>> The other question is why didn't the compiler catch this problem?
>
>The C++ front-end has trouble catching these. Try the following:
>
>  #include <windows.h>
>
>  extern int foo (LPTHREAD_START_ROUTINE);
>  static DWORD bar (void *) { return 0; }
>  static DWORD WINAPI bar2 (void *) { return 0; }
>
>  int
>  main ()
>  {
>    foo (bar);
>    foo (bar2);
>    return 0;
>  }
>
>And you'll see why I resist using anything but the cdecl calling 
>convention in my code. The C front-end does do the right thing.

Yes.  It's obviously broken.  The winsup code proves that.

cgf

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