Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

We had the C header files, but Turbo/Borland Pascal could not read them, it being a different language and all. You had to translate them into Pascal and declare each imported function as something like:

    function DirectDrawCreate(...): HRESULT; stdcall; external 'ddraw.dll';


Rudy Velthuis has a great article on the problems commonly encountered when converting C headers to Pascal (or more specifically Delphi):

http://rvelthuis.de/articles/articles-convert.html


Yep. As I said in a previous comment, I actually released a tool, called htrans, to do this, which worked very well for a lot of people.

It was a hand-coded C parser with support for a minimal subset of C++ concepts, needed to successfully translate COM interfaces. It had a bunch of kludges specifically to recognize COM. Handling macros was without doubt the most painful part of it, because I couldn't just run the .h file through a preprocessor; I had to also preserve the macros and try to convert them into declarations, so that "#define FOO 1" would result in "const FOO: Integer = 1;" or whatever. Not too bad with simple things, but sometimes people will abuse macros to declare functions...

htrans worked well enough that I could run it on a bunch of stuff and not need to edit the resulting .pas files at all. Unfortunately, I suspect I've lost the source code.


Thanks for the clarification. All of this not being helped by the weird macros COM headers used to work in both C and C++

I'm not sure whether I have nostalgia for that time or Stockholm syndrome




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: