mccu/include/mcutil/lambda.h

29 lines
764 B
C
Raw Normal View History

2025-01-28 21:42:26 +00:00
#ifndef _H_MCUTIL_LAMBDA
#define _H_MCUTIL_LAMBDA
2025-01-20 01:38:58 +00:00
#if defined(_MSC_VER) && !defined(__MC_LMBD_DEF)
2025-01-29 21:21:18 +00:00
#define __MCU_LMBD_DEF
2025-01-20 01:38:58 +00:00
#error "msc TODO"
#endif
2025-01-29 21:21:18 +00:00
#if defined(__clang__) && !defined(__MCU_LMBD_DEF)
2025-01-20 01:38:58 +00:00
#if !__has_extension(blocks)
#error "Clang blocks feature is required, compile with '-fblocks -lBlocksRuntime' \
and make sure you have libblocksruntime(-dev) installed"
#endif
2025-01-29 21:21:18 +00:00
#define __MCU_LMBD_DEF
2025-01-20 01:38:58 +00:00
#define lambda(ret_t, args_t, body) ( ^ ret_t args_t body )
#endif
2025-01-29 21:21:18 +00:00
#if defined(__GNUC__) && !defined(__MCU_LMBD_DEF)
#define __MCU_LMBD_DEF
2025-01-20 01:38:58 +00:00
#define lambda(ret_t, args_t, body) ({ ret_t lambda##__LINE__ args_t body &lambda##__LINE__; })
#endif
2025-01-29 21:21:18 +00:00
#if !defined(__MCU_LMBD_DEF)
2025-01-20 01:38:58 +00:00
#error "Unsupported compiler"
#endif
#endif