Recent

Author Topic: [SOLVED] Do we have the equivalent of h2pas for C++?  (Read 4245 times)

guest65405

  • Guest
[SOLVED] Do we have the equivalent of h2pas for C++?
« on: April 02, 2020, 05:44:34 pm »
I want to translate some C++ headers to Pascal. I used to got some small successes with h2pas so I wonder if we have something similar for C++.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Do we have the equivalent of h2pas for C++?
« Reply #1 on: April 02, 2020, 05:46:58 pm »
No. C++ interfacing is complicated.

guest65405

  • Guest
Re: Do we have the equivalent of h2pas for C++?
« Reply #2 on: April 02, 2020, 05:56:48 pm »
No. C++ interfacing is complicated.
Does something like that even planned?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Do we have the equivalent of h2pas for C++?
« Reply #3 on: April 02, 2020, 05:59:16 pm »
No. C++ interfacing is complicated.
Does something like that even planned?

It doesn't work like that. There is no universal C++ interface. Differing C++ compilers can't interface on that level with eachother. (you can't build an application in a mix of gcc and VS)

Whatever solutions there are/could be, they are for painfully crafted subsets of C++, not random C++ headers of libraries.

guest65405

  • Guest
Re: Do we have the equivalent of h2pas for C++?
« Reply #4 on: April 02, 2020, 06:04:06 pm »
No. C++ interfacing is complicated.
Does something like that even planned?

It doesn't work like that. There is no universal C++ interface. Differing C++ compilers can't interface on that level with eachother. (you can't build an application in a mix of gcc and VS)

Whatever solutions there are/could be, they are for painfully crafted subsets of C++, not random C++ headers of libraries.
Thank you. I think I should give up the hope to interface with C++ and back translating C header.

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: Do we have the equivalent of h2pas for C++?
« Reply #5 on: April 02, 2020, 08:36:41 pm »
Thank you. I think I should give up the hope to interface with C++ and back translating C header.
C header translation tools are "ok" for really simple headers.  The moment the headers go beyond really basic those tools fall apart because they are not full fledged C preprocessors and their built-in knowledge of how to _logically_ accomplish the C macros' goal in Pascal is, putting it kindly, extremely limited. 

Add to that, the "problem" that C is case sensitive and that Pascal isn't and, the result is often utterly useless.  Editing all the problems created by the translation tool takes way longer than manually converting the header.



(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

guest65405

  • Guest
Re: Do we have the equivalent of h2pas for C++?
« Reply #6 on: April 04, 2020, 09:47:51 am »
C header translation tools are "ok" for really simple headers.  The moment the headers go beyond really basic those tools fall apart because they are not full fledged C preprocessors and their built-in knowledge of how to _logically_ accomplish the C macros' goal in Pascal is, putting it kindly, extremely limited. 

Add to that, the "problem" that C is case sensitive and that Pascal isn't and, the result is often utterly useless.  Editing all the problems created by the translation tool takes way longer than manually converting the header.

Most of the headers I want to translate are fairly simple. But I also encountered some hard ones and I have to give up. Delphi Swig only worsen the problem but not help me at all. The only way is to give up. These headers need a paid professional to work on it.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: Do we have the equivalent of h2pas for C++?
« Reply #7 on: April 04, 2020, 10:54:52 am »
I would skip the paid, but keep the professional or replace it with skilled.
Specialize a type, not a var.

guest65405

  • Guest
Re: Do we have the equivalent of h2pas for C++?
« Reply #8 on: April 04, 2020, 05:30:01 pm »
I would skip the paid, but keep the professional or replace it with skilled.

I don't know any professional would do it for free without being paid  :P

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: Do we have the equivalent of h2pas for C++?
« Reply #9 on: April 04, 2020, 05:47:45 pm »
I don't know any professional would do it for free without being paid  :P
There are plenty of open source projects that are ports of C code to Pascal or other languages done by skilled/professional programmers that did it for pleasure, not money.

Of course, offering money is always a good catalyst to get it done sooner and faster. ;)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Do we have the equivalent of h2pas for C++?
« Reply #10 on: April 05, 2020, 02:28:28 pm »
I don't know any professional would do it for free without being paid  :P

I'm a professional software developer and I work on FPC in my free time. I've also played around with SWIG in my free time as well to try to get it working for FPC code, but back then my C++ skills weren't up to it.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: [SOLVED] Do we have the equivalent of h2pas for C++?
« Reply #11 on: April 05, 2020, 03:15:14 pm »
You are skilled and does most if not all for free. Big thank you!
Specialize a type, not a var.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: [SOLVED] Do we have the equivalent of h2pas for C++?
« Reply #12 on: April 05, 2020, 03:32:30 pm »
You are skilled and does most if not all for free. Big thank you!

It's my pleasure :) *curtsies*

 

TinyPortal © 2005-2018