chn-cs-htg's Avatar
chn-cs-htg 4
10 Asked
69 Answered
5 Best
0
No one has voted on this question yet :(
3 years, 3 months ago

What is the best, possibly semi-automated way, to translate C++ into C?

Tip for best answer: M$0.25
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$

What is Your Answer?

0
0
0

1 Answer

0
davepamn's Avatar
davepamn | 3 years, 2 months ago
0
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.
source(s):
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$
davepamn's Avatar
davepamn | 3 years, 2 months ago Report

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.

davepamn's Avatar
davepamn | 3 years, 2 months ago Report

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.

philipy's Avatar
philipy | 3 years, 2 months ago Report

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

Report Abuse

Post Reply Cancel

Learn something new with our FREE educational apps!

Private lessons in the comfort of your own home. Get back in shape or finally pick up a guitar with our great experts guiding you the whole way!
Learn Guitar
Learn Hip Hop
Learn Pilates