ThreadFunctionType, ITK_THREAD_RETURN_TYPE, and 32-bit Windows

Hi, I encountered a problem on 32-bit windows for ITK 5.X. In ITK 4, thread functions were defined as follows:

typedef unsigned(__stdcall * ThreadFunctionType)(void *);
#define ITK_THREAD_RETURN_TYPE unsigned __stdcall

In ITK 5.X it is defined as follows:

using ThreadFunctionType = unsigned(__stdcall *)(void *);
using ITK_THREAD_RETURN_TYPE = unsigned;

Note the loss of __stdcall in ITK_THREAD_RETURN_TYPE. As a result, the following code doesn’t compile on 32-bit. It compiles on 64-bit because AFAIK __stdcall is ignored.

static 
itk::ITK_THREAD_RETURN_TYPE
main_thread (void* param)
{
}

Am I doing it wrong? Thanks!

I have not tried to compile ITK in 32-bit mode in a long time. I am not sure anyone has. And I don’t remember whether we support it any more.

You could make a PR which adds __stdcall to ITK_THREAD_RETURN_TYPE and see whether the CI complains about it. If not, and it fixes your problem, we could merge it.

Thanks! Actually, I think I figured it out on my own. There is the following #define which looks like what is needed:

#  define ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION itk::ITK_THREAD_RETURN_TYPE __stdcall

I’ll post again when I have a chance to test it.

1 Like

Just reporting back. This works perfectly on 32-bit and 64-bit Windows (and also on Linux). I used it like this:

static 
ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
main_thread (void* param)
{
}
1 Like