cross compiling

How to convert a C++ source code to a C source code. Is there any cross compiler for this already available.
or How to extract the properties of C++ (Inheritance, Polymorphism and Encapsulation) into the C Code.

How to go about doing the C++ source code to C source code
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gaatriAuthor Commented:
I need it very importantly.
so, can u make it fast.
Early C++ compilers used a pre-processor (cfront mostly) to convert C++ into C which would then be fed through a C compiler.

Of course these days nobody in their right mind would build a compiler in such a way.

Unless you can get hold of an old cfront based compiler (by the way it probably won't support templates or exceptions or a host of other stuff) I reckon you're stuffed.
There are modern compilers that do it this way (and no real reason why not).  The kai compiler ( is a very highly regarded optimizing C++ compiler that works this way.

But...if you expect the C code produced to be human editable/readable/maintainable, then I should forget the whole idea.
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

You can translate C++ code to C code. You will have to find out whether your compiler support that or not. I am working on HP-UX. This has option to do that like
CC +i <nameofC++file>
It is supported on HP-C++ 12.10. So you just look in to different compile option and take help from help/programmer guide provided on unix system.

But it not a good idea. Because the genarated code will run into thousand line, and you may find it very difficult to understand and maintain.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gaatriAuthor Commented:
Is there any other solution for converting C++ code to C,since presently I don't have HP-C++12.10,since my task is to completed immediately ,I would like to have an immediate solution to this.
Also if you can give me the guidelines
and suggestions on how to go about in converting the C++ code to C code keeping intact the characteristics of the oops concept,it would be helpful
PL reply immediately.
What you are asking is basically impossible without a lot of work.  i.e. to retain the OO characteristics in a C implementation, you would have to write a C framework which provided the required facilities.

BTW, none of the C++ compilers that generate C code will provide what you want,  they are -compiling- the code, and the back end is C.  Do not expect the generated code to be readable.

Why do you need this?  There are not many platforms that don't have a C++ compiler.
What do you need it for? Will you keep a C 'mirror' of an app coded in C++? Are you curious about the implementation?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.