Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-03

Re: Help needed with interfacing to C-object-files

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jeff Pohlmeyer
Last question to Jeff Pohlmeyer : could you explain how you made that unit ?

Hello, Koenraad...

There is not really a one-size-fits-all solution to this, but in general this is what I did for this particular case:

# be sure to clean up any leftovers first:

rm -f all.h all_inc.h all_mac.h

# create a header that #include's all the other headers:

ls -1 *.h | awk '{printf("#include \"%s\"\n", $1)}' > all.h

# process the header through the C preprocessor,
# most warnings here can probably be ignored:

cpp -P -nostdinc all.h > all_inc.h

# re-process the header to extract the #define macro's:

cpp -dM -P -nostdinc all.h | grep -v '__' > all_mac.h

From here, you should be able to process the two resulting

files "all_inc.h" and "all_mac.inc" with h2pas.

Of course, there will always be a few "tweaks" to the headers ( and the output files ) to get everything working.

For instance, the "static array of ThermoScript" stuff simply has to be translated by hand.

I used my own heavily modified version of h2pas, it does some tricks like sorting the ouput by data type, and handling "anonymous" enumerations, but the default version of h2pas should get you pretty close.

Good Luck!

- Jeff

__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/

Reply by email