[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
C++ to C converter/compiler
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 23
Thread images: 2
File: 1442343519319.jpg (133 KB, 640x480) Image search: [Google]
1442343519319.jpg
133 KB, 640x480
Looking for a tool to convert some C++ code into C; doesn't have to be a readable conversion just needs to work.
>>
>>51626610
Protip
Compile c++ code
Decompile into c code
Also why would you want this
>>
mv source.cpp source.c
>>
>>51626657
Have C++ code i want to run on a C only microprocessor, and I'd thought getting it automatically translated rather than manually going through it would be the easiest way to know if it would work on the micro.
>>
>>51626728
No. Just don't. There's a reason it's C only.
>>
>>51626868
Why? I'm trying port some code from github (espduino) from arduino to a PIC micro, and part of the espduino is in C++ (most in C) but it just seems to be using classes make the low level shit easier to look at, hence i was thinking of C++ to C to see of it will all work before having to manually do it and get bogged down in low level shit.
>>
>>51626728

oh please anon let me google that for you, here we go....

http://llvm.org/releases/3.1/docs/FAQ.html#translatecxx

no no, dont thank me.
>>
>>51626950

hmmm something doesnt smell right.
anything written in c++ can be written in c.
so i'm not sure what you're hoping to prove.
is there some specific hardware related stuff in the code that may or may not work and thats what you're attempting to "prove"?
>>
>>51627011
>is there some specific hardware related stuff in the code that may or may not work and thats what you're attempting to "prove"?
Basically I'm not 100% confident i can translate it from C++ to C directly, or at least in a reasonable time frame, hence I'm curious about translation and shit.

It's fairly low-level stuff, hence why I'm asking.
>>
Follow up: after trying several versions of LLVM with various errors ranging from no C backend to the build's failing (currently using 3.0 rc1), i got a .c program from a Hello World C++ file but no compile on either my Linux VM or mingw in windows.
>>
>>51629815
no one fucking cares
>>
>>51629830
Sorry, is this one thread about technology a distraction from the usual graphics cards/botnet/phone general circlejerks?
>>
>>51626950
Classes make it harder to look at.
>>
>>51629815
You're trying to change programming paradigms, paradigms are a concept for the human brain only and the computer doesn't know the difference. It's not going to be something where you can just click a button and a perfect rewrite is created.

Don't want to sound like a typical 4chan user but, git gud and rewrite from scratch.
>>
why not rewrite the thing in C?
If you are using some obscure microprocessor, you probably have spatial limitations as well so it can't be that big.
>>
>>51626728
>C only microprocessor
What this even means?
>>
>>51630874
Probably means he's stuck with a shitty PIC toolchain from 20 years ago.
>>
>>51630874
It means its an old microprocessor. Cpus started supporting classes only since 1992.
>>
>>51630670
I probably should have stated in the OP, but i fully understand the outputted C file will be unintelligible, i just wanted to go from C++ to C to onto my target microprocessor in a quick way for prototyping. Also i was genuinely curious about the concept if coding in one language, converting it, and running it but in a different language.

If i had a stack that took C++ and turned it into the most incomprehensible rubbish C i wouldn't care as long as it ran.

But after bashing my head against a wall for most of today, I'll have to follow you and >>51630852's advice and git gud.
>>
>>51630994
Say you get the conversion working correctly then what?
If your initial application is too large would you optimize the c++ code?
>>
File: 1446031638737.jpg (11 KB, 240x196) Image search: [Google]
1446031638737.jpg
11 KB, 240x196
>>51626610
>being this dumb
>>
>>51631077
If the conversion bloated it I'd probably drop it and manually translate it.

Honestly i thought I'd find something that would spit out C from C++ in whatever form, put it onto the platform and try and get a quick prototype up and running.
>>
>>51631188
glib is a decent replacement for STL
Thread replies: 23
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.