Revision as of 07:44, 27 May 2016 by Admin (talk | contribs) (→‎Notes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Source File



#define LIBSHARED_PAL_THREAD_RETURN_CAST( return_value )  return_value


#define LIBSHARED_PAL_THREAD_RETURN_CAST( return_value )


#define LIBSHARED_PAL_THREAD_RETURN_CAST( return_value )


This define is mandatory and the library cannot compile if it is not set.


Windows kernel mode threads are unique in that the thread function returns void. As such, two problems are presented; firstly, the existing code, which is cross-platform and so has thread functions which return a variable, often attempts to declare on the stack a variable of the type libshared_pal_thread_return_t, which is set to a value during the course of operation and then returned. However, if libshared_pal_thread_return_t is void, then the compiler throws an error, because it is not possible to declare variables of type void. Secondly, the return from the thread function must be empty - where all the existing threads are returning a value or variable.

To solve this, one define (LIBSHARED_PAL_THREAD_RETURN_TYPE) and this macro are provided. This define provides for Windows kernel a harmless type which will permit the thread function code to compile. This macro wraps the return argument and on Windows kernel, consumes it - makes it disappear - by being an empty macro. On other platforms, the macro itself disappears, leaving just its argument, which then gives us what we want in both cases.

See Also