Is there any up to date C++ to C converter?

This is a discussion on Is there any up to date C++ to C converter? within the C Programming forums, part of the General Programming Boards category; On google I found only informations about cfront, which is now outdated, no longer sold and not supporting newer standard. ...

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    88

    Is there any up to date C++ to C converter?

    On google I found only informations about cfront, which is now outdated, no longer sold and not supporting newer standard.

    Is there any other C++ to C converter?

    The code doesn't need to be well readable, this would just be a cool addition but is not a requirement. It must just output well portable C code which can be compiled using a C compiler.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Did you check your other thread?

    Adding C++ support to C thought library?

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    88
    Yes, it inspired me to look for it.

    The listed converters are weak.
    - Cfron is outdated, no question.
    - Comeau C++ is not free, it's expensive and it's no "real" conversation. It creates C code for the specific platform, but it doesn't exactly exchange for example free wit delete (maybe it does, just for example). It creates platform specific code.
    - http://www.nondot.org/~sabre/Projects/, link down
    - LLVM, no windows version, site is hard to understand, from description on wikipedia it says nothing about converting C++ to C and also on their site is nothing about C++ to C. Guess it also creates platform specific C object code?

    From that view, the original question is still in.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    > LLVM, no windows version,

    it's in the downloads section.

    > site is hard to understand,

    not to me.

    >from description on wikipedia it says nothing about converting C++ to C and also on their site is nothing about C++ to C.

    the direct link I posted to their official website overrides wikipedia.

    > Guess it also creates platform specific C object code?

    Platform specific C object code? What are you talking about? There is no such thing. If it's object code, it's binaries, and C code is not a binary.

  5. #5
    Registered User
    Join Date
    Jul 2007
    Posts
    88
    Quote Originally Posted by robwhit View Post
    Platform specific C object code? What are you talking about? There is no such thing. If it's object code, it's binaries, and C code is not a binary.
    Dunno what I have just wrote about object.

    Have you tried it?

    I am reading here.
    http://llvm.org/docs/FAQ.html#translatec++

    The three lines
    % llvm-g++ a.cpp -c
    % llvm-g++ b.cpp -c
    % llvm-g++ a.o b.o -o program
    work for me on widnows and program is executable.

    But program.bc will not be created. Idea why?

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,777
    Again, why do you need to compile it as C or convert C++ to C?
    Specifics please! You say you have a library in C, but it's possible to bridge gaps between C and C++ very easily. A lot of people can help you, if you just give us specifics on what you're trying to do and HOW!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Jul 2007
    Posts
    88
    Quote Originally Posted by Elysia View Post
    Again, why do you need to compile it as C or convert C++ to C?
    Specifics please! You say you have a library in C, but it's possible to bridge gaps between C and C++ very easily. A lot of people can help you, if you just give us specifics on what you're trying to do and HOW!
    Well, there are a lot of C++ compilers not supporting most useful features such as templates or stringstreams. Sure anyone can argue these features are not needed but that's a personal preference, a bit like religion. There are also lots of platforms (embedded) which doesn't even have a C++ compiler, but a C compiler.

    I am very curious about this C++ to C conversation and would like to get the thing discussed in my previous post to work.

  8. #8
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by sept View Post
    There are also lots of platforms (embedded) which doesn't even have a C++ compiler, but a C compiler.
    Two things there. If you're working on a normal *nix system or even a windows machine, getting a good C++ compiler is about as difficult as opening your browser and looking for them.
    The other, if you're writing for an embedded system, you don't want all the crap from C++ anyway. What's the point in having templates and stringstreams, when you can only use 1k of memory?

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  9. #9
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,777
    Quote Originally Posted by QuantumPete View Post
    The other, if you're writing for an embedded system, you don't want all the crap from C++ anyway. What's the point in having templates and stringstreams, when you can only use 1k of memory?
    That sounds like a flaming anti-C++ statement. I'd say who needs a crap embedded system with 1k of memory instead?
    Point is, templates, stringstreams & co are not crap but very useful stuff, and it's simply that the embedded system is too weak to support a modern language.
    The embedded system is at fault and not C++.

    Quote Originally Posted by sept View Post
    Well, there are a lot of C++ compilers not supporting most useful features such as templates or stringstreams.
    Oh really? There are plenty of well-compliant compilers out there that supports these features very well.
    Visual C++ and GCC among them comes to mind.

    There are also lots of platforms (embedded) which doesn't even have a C++ compiler, but a C compiler.
    Yes, and that's a very big darn shame. You'd think that today we'd be over such limitations that embedded systems could support C++ seeing as C is an old language, not up-to-date with today's requirements.
    It's a shame.
    But then again, what are you targeting? Desktop or embedded?
    If it's embedded, you probably can't use any C++ stuff anyway.

    I am very curious about this C++ to C conversation and would like to get the thing discussed in my previous post to work.
    But you never really mentioned why you need to compile it as C, or at least failed to give specifics.
    Because it's possible to mix C and C++.
    Last edited by Elysia; 09-10-2008 at 11:05 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by Elysia View Post
    That sounds like a flaming anti-C++ statement.
    Wasn't meant to be.
    Quote Originally Posted by Elysia View Post
    The embedded system is at fault and not C++.
    Absolutely. I'm just saying that *if* you have only 1k of memory, C++ is not your best bet.

    QuantumPete
    Edit: I didn't mean "crap" as in those features in C++ are crap! It was meant in the sense of "lots of extra stuff, which you don't need in this case, because it adds more overhead to your code on a system that doesn't have all that much memory"... I just shortened it
    Last edited by QuantumPete; 09-10-2008 at 11:31 AM.
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  11. #11
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,777
    Looks like you got out your meaning wrong then
    But now that you've cleared it up, we're in agreement!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    When I only want a program working within 1k of memory, I usually tend to argue that C adds too much bloat too. But now I am just being picky. I am going to make the blanket statement that a program for doing such conversions is unnecessary. There is little reasonable necessity to make such a conversion and anyone can go ahead and argue with me all they want but I will still refute the technical merrit of the conversion.

  13. #13
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by master5001 View Post
    When I only want a program working within 1k of memory, I usually tend to argue that C adds too much bloat too. But now I am just being picky. I am going to make the blanket statement that a program for doing such conversions is unnecessary. There is little reasonable necessity to make such a conversion and anyone can go ahead and argue with me all they want but I will still refute the technical merrit of the conversion.
    But if you translate C++ into C using machine translation, it will most likely just generate the same amount of code as if you directly compiled the C++ code - give or take a little tiny bit depending on how good the C++ to C translator is, and how well the C compiler does with the generated code - reading the page mentioned above, it appears that the llvm takes C++ code and compiles it, then reverts the generated half-compiled code into C, and it uses gotos instead of proper loops for example. So it may not make very pretty code.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  14. #14
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Fair enough, however if you are trying to budget yourself within a very small amount of memory, it doesn't hurt to write your program in assembler over C anyway.

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by master5001 View Post
    Fair enough, however if you are trying to budget yourself within a very small amount of memory, it doesn't hurt to write your program in assembler over C anyway.
    Sure. But it becomes (much) harder to convert it to a different architecture - but then if it's only a few hundred or thousand lines of assembler, it's not a huge deal, I suppose.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advancing day by day until it matches a second date
    By nhubred in forum C++ Programming
    Replies: 1
    Last Post: 05-30-2009, 08:55 AM
  2. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  3. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 04:23 PM
  4. CDate Class - handle date manipulation simply
    By LuckY in forum C++ Programming
    Replies: 5
    Last Post: 07-16-2003, 08:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21