[fpc-pascal] Re: Help needed with interfacing to C-object-files

Jeff Pohlmeyer yetanothergeek at yahoo.com
Thu Mar 17 19:32:27 CET 2005


> 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/ 




More information about the fpc-pascal mailing list