c - 在普通 C(msvc) 中模拟 lambdas - 递归 lambdas
问题描述
因此,我面临在 msvc 编译器(它不支持 gcc 扩展)上模仿纯 C 中的 lambda 定义的挑战——我想出了一个文件包含解决方案,它基本上反映了顶部的文件。它适用于大多数情况,但如果我想在我的 lambda 中包含一个 lambda:
#ifndef FIRSTPASS
#include <stdio.h>
//here comes your "nested" definitions
#define FIRSTPASS
#include "source.c"
#undef FIRSTPASS
main(){
#else
int global = 2;
int func()
{
//define another "lambda" here
printf("%d\n", global);
}
#endif
#ifndef FIRSTPASS
func();}
#endif
解决方案
推荐阅读
- kotlin - 如何使 Kotlin 的内联类构造函数对 groovy 可见?
- oracle - ORA-00600: 内部错误代码, 参数: [kdliReadPos], [27206], [1164], [0], [0], [], [], [], [], [], [], []
- laravel - Laravel 使用无条件查找和动态 where 条件
- c# - 在 Azure Function 中覆盖 function.json 的问题
- android - 如何处理父视图上的触摸事件?
- java - 如何使用片段和顶点着色器使 2D 纹理表面不均匀?从纹理中删除某些像素?
- javascript - 为什么喜欢和不喜欢不能正常工作
- string - 打印两个字符串中相同且出现在相同位置的字符数
- sequelize.js - Sequelize 将 2 个查询组合为 sub where
- javascript - 提高计算两点之间距离的性能