3 years, 3 months ago
What is the best, possibly semi-automated way, to translate C++ into C?
Separate topics with commas, or by pressing return. Use the delete or backspace key to edit or remove existing topics.
You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.
M$1 Answer
Wow! Void pointers, c structs, ect, enumeration types, etc.
I remember as a student learning how to create C++ using C, so it is possible to reverse the class, methods, and attributes into C structures. I would write a parser to do the conversion.
Inheritance will need to be encapsulated single level inheritance. Polymorphism is possible by not recommended. It would be based on type and void pointers.
A method can be created using a pointer function. A class can be a structure. Indirect referencing can be points. Void pointers are good because they can ignore type. You can typecast the variables.
I remember as a student learning how to create C++ using C, so it is possible to reverse the class, methods, and attributes into C structures. I would write a parser to do the conversion.
Inheritance will need to be encapsulated single level inheritance. Polymorphism is possible by not recommended. It would be based on type and void pointers.
A method can be created using a pointer function. A class can be a structure. Indirect referencing can be points. Void pointers are good because they can ignore type. You can typecast the variables.
source(s):
Att C++
Att C++
You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.
M$
Let me know, if your project has any budget and I may be willing to write a C++ to C parser.
precompile C is human non readable.
Another worthy project is a Cobol to C converter.
A C structure can replace the class. The methods are void pointer functions. You use alloc or maloc to instantiate the structure and reference the void pointer function for the method. C structures can encapsulate other c structures through a link list. This is your encapsulated inheritance. Similar to VB inheritance.
Look at the Comeau C/C++ compiler:
http://www.comeaucomputing.com/
It works by pre-processing C++ into a C dialect specific to a particular compiler and platform, and then compiling that C into object code with the chosen compiler. It's an up-to-date version of the way C++ was originally handled using the cfront pre-processor.
http://en.wikipedia.org/wiki/Cfront