# quick question about __stdcall at run-command.c mingw.c

6 messages from 2009-08-16 to 2009-08-17. Participants: Frank Li, Pat Thoyts, Johannes Sixt, Johannes Schindelin.
Thread: https://gitlist.dev/t/20619

## Frank Li, 2009-08-16 23:19

Subject: quick question about __stdcall at run-command.c mingw.c
Message-ID: <1976ea660908161619x5182762sade051f24fef13db@mail.gmail.com>
URL: https://gitlist.dev/e/1976ea660908161619x5182762sade051f24fef13db%40mail.gmail.com

```

I am tring to clear VC build patch.

I found __stdcall position break MSVC build.

static __stdcall unsigned run_thread(void *data)

MSVC require __stdcall should be between return type and function name.
like
static unsigned __stdcall run_thread(void *data)

I think msys gcc should support MSVC format.

Should I directly change to MSVC format or add _MSC_VER marcro like

#if defined(__MINGW32__)
static __stdcall unsigned run_thread(void *data)
#elif defined(_MSC_VER) /*MSVC must put __stdcall between return value
and function*/
static unsigned __stdcall run_thread(void *data)
#endif

```

## Pat Thoyts, 2009-08-17 00:03

Subject: Re: [msysGit] quick question about __stdcall at run-command.c mingw.c
Message-ID: <a5b261830908161703l2296448l698d07d01ae8a6d3@mail.gmail.com>
URL: https://gitlist.dev/e/a5b261830908161703l2296448l698d07d01ae8a6d3%40mail.gmail.com
In-Reply-To: <1976ea660908161619x5182762sade051f24fef13db@mail.gmail.com>

```
2009/8/17 Frank Li <lznuaa@gmail.com>:
>
> I am tring to clear VC build patch.
>
> I found __stdcall position break MSVC build.
>
> static __stdcall unsigned run_thread(void *data)
>
> MSVC require __stdcall should be between return type and function name.
> like
> static unsigned __stdcall run_thread(void *data)
>
> I think msys gcc should support MSVC format.
>
> Should I directly change to MSVC format or add _MSC_VER marcro like
>
> #if defined(__MINGW32__)
> static __stdcall unsigned run_thread(void *data)
> #elif defined(_MSC_VER) /*MSVC must put __stdcall between return value
> and function*/
> static unsigned __stdcall run_thread(void *data)
> #endif

The win32 api prototype used for thread entry functions is declared as
a DWORD (WINAPI *LPTHREAD_START_ROUTINE)(LPVOID) type in the mingw
headers and WINAPI as #define WINAPI __stdcall. This is true for the
MSVC headers as well. So gcc and msvc are happy using the same
definition for such a function and just "static unsigned long WINAPI
run_thread(void *)" might well be sensible.

```

## Johannes Sixt, 2009-08-17 07:52

Subject: Re: [msysGit] quick question about __stdcall at run-command.c mingw.c
Message-ID: <4A890C32.6010507@viscovery.net>
URL: https://gitlist.dev/e/4A890C32.6010507%40viscovery.net
In-Reply-To: <a5b261830908161703l2296448l698d07d01ae8a6d3@mail.gmail.com>

```
Pat Thoyts schrieb:
> 2009/8/17 Frank Li <lznuaa@gmail.com>:
>> I am tring to clear VC build patch.
>>
>> I found __stdcall position break MSVC build.
>>
>> static __stdcall unsigned run_thread(void *data)
>>
>> MSVC require __stdcall should be between return type and function name.
>> like
>> static unsigned __stdcall run_thread(void *data)
>>
>> I think msys gcc should support MSVC format.
>>
>> Should I directly change to MSVC format or add _MSC_VER marcro like
>>
>> #if defined(__MINGW32__)
>> static __stdcall unsigned run_thread(void *data)
>> #elif defined(_MSC_VER) /*MSVC must put __stdcall between return value
>> and function*/
>> static unsigned __stdcall run_thread(void *data)
>> #endif
> 
> The win32 api prototype used for thread entry functions is declared as
> a DWORD (WINAPI *LPTHREAD_START_ROUTINE)(LPVOID) type in the mingw
> headers and WINAPI as #define WINAPI __stdcall. This is true for the
> MSVC headers as well. So gcc and msvc are happy using the same
> definition for such a function and just "static unsigned long WINAPI
> run_thread(void *)" might well be sensible.

Change the code to

	static unsigned __stdcall run_thread(void *data)

The documentation explictly says: "The routine at start_address passed to
_beginthreadex must use the __stdcall calling convention...". So __stdcall
it is.

-- Hannes

```

## Johannes Schindelin, 2009-08-17 08:21

Subject: Re: [msysGit] quick question about __stdcall at run-command.c mingw.c
Message-ID: <alpine.DEB.1.00.0908171018490.4991@intel-tinevez-2-302>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0908171018490.4991%40intel-tinevez-2-302
In-Reply-To: <4A890C32.6010507@viscovery.net>

```
Hi,

On Mon, 17 Aug 2009, Johannes Sixt wrote:

> Pat Thoyts schrieb:
> > 2009/8/17 Frank Li <lznuaa@gmail.com>:
> >> I am tring to clear VC build patch.
> >>
> >> I found __stdcall position break MSVC build.
> >>
> >> static __stdcall unsigned run_thread(void *data)
> >>
> >> MSVC require __stdcall should be between return type and function 
> >> name. like static unsigned __stdcall run_thread(void *data)
> >>
> >> I think msys gcc should support MSVC format.

I think that it does.

But it is _your_ duty to check.

> >> Should I directly change to MSVC format or add _MSC_VER marcro like
> >>
> >> #if defined(__MINGW32__)
> >> static __stdcall unsigned run_thread(void *data)
> >> #elif defined(_MSC_VER) /*MSVC must put __stdcall between return value
> >> and function*/
> >> static unsigned __stdcall run_thread(void *data)
> >> #endif

Noooo! NO _MSC_VER crap in mingw.c.  Really.  I am able to repeat that as 
often as you want me, but I'd prefer not to.

> > The win32 api prototype used for thread entry functions is declared as
> > a DWORD (WINAPI *LPTHREAD_START_ROUTINE)(LPVOID) type in the mingw
> > headers and WINAPI as #define WINAPI __stdcall. This is true for the
> > MSVC headers as well. So gcc and msvc are happy using the same
> > definition for such a function and just "static unsigned long WINAPI
> > run_thread(void *)" might well be sensible.
> 
> Change the code to
> 
> 	static unsigned __stdcall run_thread(void *data)
> 
> The documentation explictly says: "The routine at start_address passed to
> _beginthreadex must use the __stdcall calling convention...". So __stdcall
> it is.

I could not agree more.

Ciao,
Dscho

```

## Johannes Sixt, 2009-08-17 08:43

Subject: Re: [msysGit] quick question about __stdcall at run-command.c mingw.c
Message-ID: <4A891840.4050403@viscovery.net>
URL: https://gitlist.dev/e/4A891840.4050403%40viscovery.net
In-Reply-To: <alpine.DEB.1.00.0908171018490.4991@intel-tinevez-2-302>

```
Johannes Schindelin schrieb:
> On Mon, 17 Aug 2009, Johannes Sixt wrote:
>> Pat Thoyts schrieb:
>>> 2009/8/17 Frank Li <lznuaa@gmail.com>:
>>>> I am tring to clear VC build patch.
>>>>
>>>> I found __stdcall position break MSVC build.
>>>>
>>>> static __stdcall unsigned run_thread(void *data)
>>>>
>>>> MSVC require __stdcall should be between return type and function 
>>>> name. like static unsigned __stdcall run_thread(void *data)
>>>>
>>>> I think msys gcc should support MSVC format.
> 
> I think that it does.
> 
> But it is _your_ duty to check.

Cool down. Asking for "please could you check whether this works" *if* you
don't have the infrastructure to test it yourself is certainly dutyful enough.

Do you have an Irix, Solaris, HP box on your desk next to your Linux, so
that you don't have to ask others to test your patches?

-- Hannes

```

## Johannes Schindelin, 2009-08-17 09:12

Subject: Re: [msysGit] quick question about __stdcall at run-command.c mingw.c
Message-ID: <alpine.DEB.1.00.0908171109091.4991@intel-tinevez-2-302>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0908171109091.4991%40intel-tinevez-2-302
In-Reply-To: <4A891840.4050403@viscovery.net>

```
Hi,

On Mon, 17 Aug 2009, Johannes Sixt wrote:

> Johannes Schindelin schrieb:
> > On Mon, 17 Aug 2009, Johannes Sixt wrote:
> >> Pat Thoyts schrieb:
> >>> 2009/8/17 Frank Li <lznuaa@gmail.com>:
> >>>> I am tring to clear VC build patch.
> >>>>
> >>>> I found __stdcall position break MSVC build.
> >>>>
> >>>> static __stdcall unsigned run_thread(void *data)
> >>>>
> >>>> MSVC require __stdcall should be between return type and function 
> >>>> name. like static unsigned __stdcall run_thread(void *data)
> >>>>
> >>>> I think msys gcc should support MSVC format.
> > 
> > I think that it does.
> > 
> > But it is _your_ duty to check.
> 
> Cool down. Asking for "please could you check whether this works" *if* 
> you don't have the infrastructure to test it yourself is certainly 
> dutyful enough.
> 
> Do you have an Irix, Solaris, HP box on your desk next to your Linux, so 
> that you don't have to ask others to test your patches?

This is Windows.  Frank has Windows.

Downloading msysGit does not incur any cost.  Actually running the whole 
thing from the net installer just takes a little time and a two-digit 
megabyte download.

I put a lot of work into making this procedure as painless to use (for 
other people, it caused me a lot of pain).  So Frank might just as well 
not let my effort go to hell.

Of course, Frank could ask one of the few msysGit contributors to try to 
compile something he prepared, wait for the results and possibly fix 
things for another round.  This appears as a rather poor use of 
everybody's time, methinks.

Ciao,
Dscho

```
