views:

126

answers:

1

i need a tool that can convert c/c++ code to delphi(object pascal) code, have tried openc2pas but it is pretty much useless and a pain to use is their a usable alternative?(free or commercial)

+6  A: 

Unless you need this for academic purposes, stop looking, because:

  • Delphi doesn't support everything that's supported in C++. Examples: Delphi doesn't support operator overloading. Delphi can't instantiate class instances on stack (all Delphi objects are dynamically allocated, using the equivalent of the C++ "new" operator)
  • The language itself is not all. You'll need equivalent libraries for every C++ library you used!
Cosmin Prund
thanks 4 the reply,basically i need something to convert a basic c code snippet with some windows api code in it into pascal, any tool for that job?
Omair Iqbal
actually; Delphi 2006 and up support operator overloading on records, see here for a list you can overload: http://wiert.wordpress.com/2009/10/19/delphi-operator-overloading-table-of-operators-names-and-some-notes-on-usage-and-glitches/
Jeroen Pluimers
Rob Kennedy
If you go the search and replace route, here's some more -{ } -> begin end;void -> procedure;int x -> x: integer; (would probably need regex for this one)
Alan Clark
is it a good idea to learn 2 languages if you havent mastered 1st language ,i am teaching my self pascal/delphi as my first language and i fear i will mix 2 langages if i try learning another(just like they say you should not learn french and german together,i think same hold true for computer languages or not???)
Omair Iqbal
Yes, Omair, it is always a good idea to learn to read C. You don't have to learn to *write* C — that's an entirely different challenge — and you don't have to learn all the details, but you should be able to look at a basic C function and get a general idea of what's going on. Most of the Windows and Unix code you'll see from other people is written in C. To learn it, simply *read that code*. You'll be tempted to immediately give up because you "don't know C," but if you try, you'll find it's not actually very hard to read. Compilers will catch you quickly if you attempt to mix two languages.
Rob Kennedy