This commit is contained in:
Gvidas Juknevičius 2025-01-20 03:38:58 +02:00
commit 4433f2dd84
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB

28
mccu/include/lambda.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef _H_MCORANGE_LAMBDA
#define _H_MCORANGE_LAMBDA
#if defined(_MSC_VER) && !defined(__MC_LMBD_DEF)
#define __MC_LMBD_DEF
#error "msc TODO"
#endif
#if defined(__clang__) && !defined(__MC_LMBD_DEF)
#if !__has_extension(blocks)
#error "Clang blocks feature is required, compile with '-fblocks -lBlocksRuntime' \
and make sure you have libblocksruntime(-dev) installed"
#endif
#define __MC_LMBD_DEF
#define lambda(ret_t, args_t, body) ( ^ ret_t args_t body )
#endif
#if defined(__GNUC__) && !defined(__MC_LMBD_DEF)
#define __MC_LMBD_DEF
#define lambda(ret_t, args_t, body) ({ ret_t lambda##__LINE__ args_t body &lambda##__LINE__; })
#endif
#if !defined(__MC_LMBD_DEF)
#error "Unsupported compiler"
#endif
#endif