1

While casually exploring the function definitions in some built-in header files, i found something in some function parameter lists, that confuses me:

#ifdef __BLOCKS__
int  heapsort_b(void *__base, size_t __nel, size_t __width,
        int (^ _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
#endif /* __BLOCKS__ */
int  mergesort(void *__base, size_t __nel, size_t __width,
        int (* _Nonnull __compar)(const void *, const void *));
#ifdef __BLOCKS__
int  mergesort_b(void *__base, size_t __nel, size_t __width,
        int (^ _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
#endif /* __BLOCKS__ */
void     psort(void *__base, size_t __nel, size_t __width,
        int (* _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
#ifdef __BLOCKS__
void     psort_b(void *__base, size_t __nel, size_t __width,
        int (^ _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
#endif /* __BLOCKS__ */
void     psort_r(void *__base, size_t __nel, size_t __width, void *,
        int (* _Nonnull __compar)(void *, const void *, const void *))  __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
#ifdef __BLOCKS__
void     qsort_b(void *__base, size_t __nel, size_t __width,
        int (^ _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
#endif /* __BLOCKS__ */

If you look closely, some of those sorting functions have a ^-character before the comparator function type. Until now, i have never seen this character in this context, and it confuses me.

My questions are:

Is this valid code ?

What does the caret-character do in this context?

Where does the __BLOCKS__ macro come from?

Is the __BLOCKS__ macro influential for this phenomenon?

I'm programming with XCode on macOS Mojave version 10.14.6.

Phridge
  • 148
  • 8

0 Answers0