如何C ++ code转换为C [英] How to convert C++ Code to C
问题描述
我有一些C ++ code。在code有定义这些类的许多类,其成员函数,构造函数,析构函数,几个模板类和大量的C ++的东西。现在我需要源转换成普通的C code。
我的有以下几个问题:
-
有没有C ++ code和头文件转换为C code任何工具?
-
请问我需要做的code的完全重写(我将不得不删除构造函数,析构函数和移动的code到一些
的init()
,DEINIT()
功能;改变类的结构,使现有的成员函数中的新定义的结构函数指针,然后使用函数指针调用等这些功能。)? -
如果我必须把它转换手动自己,什么C ++特定code数据结构/语义我需要注意,而从C ++执行转换为C?
有的确是这样的一个工具,科莫的C ++编译器。 。它会生成C code,你不能手工维护,但是这是没有问题的。你可以保持在C ++ code和只是转换为C的飞行。
I have some C++ code. In the code there are many classes defined, their member functions, constructors, destructors for those classes, few template classes and lots of C++ stuff. Now I need to convert the source to plain C code.
I the have following questions:
Is there any tool to convert C++ code and header files to C code?
Will I have to do total rewrite of the code (I will have to remove the constructors,destructors and move that code into some
init()
,deinit()
functions; change classes to structures, make existing member functions as function pointers in those newly defined structures and then invoke those functions using function pointers etc..)?If I have to convert it manually myself, what C++ specific code-data constructs/semantics do I need to pay attention to while doing the conversion from C++ to C?
There is indeed such a tool, Comeau's C++ compiler. . It will generate C code which you can't manually maintain, but that's no problem. You'll maintain the C++ code, and just convert to C on the fly.
这篇关于如何C ++ code转换为C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!