需要将C ++模板转换为C99代码 [英] need to convert C++ template to C99 code

查看:414
本文介绍了需要将C ++模板转换为C99代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将CUDA代码移植到OpenCL - CUDA允许C ++构造像模板,而OpenCL严格C99。那么,什么是最无痛的方式移植模板到C?
我想到为模板参数使用函数指针。

I am porting CUDA code to OpenCL - CUDA allows C++ constructs like templates while OpenCL is strictly C99. So, what is the most painless way of porting templatest to C? I thought of using function pointers for the template parameters.

推荐答案

在有模板之前,有预处理器宏。

Before there were templates, there were preprocessor macros.

在网络上搜索C中的通用编程获取灵感。

Search the web for "generic programming in C" for inspiration.

这篇关于需要将C ++模板转换为C99代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆