Re: C Header Files -> Pascal
According to Sven Engelhardt:
I agree. Though IMHO there already exist such tools. Possibly I will do this ... (if there aren't any parser-specialist)
I don't know any parser-specialist. (No, I am not one either.;) I also have never seen any working converter. It would be highly welcome if you would write one!
Or may be there is a way to use C .h files directly by slightly modifiying the preprocessor. This would be a really great deal for guys like me that permanently update some library-version...
This would mean nothing else than to build the converter program into GPC - making GPC understand C source in effect. I don't think this is a good idea. The only reasonable thing I can imagine in this context would be to write a preprocessor switch which changes the language during the compilation, e.g. Program FooBar; Var Foo: Integer; #language C int bar; void setbar (void) { bar = foo; } #language Pascal begin Foo:= 3; SetBar; end. or, when the C part is in a header file, Program FooBar; Var Foo: Integer; #language C #include "bar.h" #language Pascal begin Foo:= 3; SetBar; end. ... but such a thing would be *very* hard to write. If you really must rely on C headers which change from time to time, it is probably the most reasonable thing to write a C module which uses the header files and exports some well-defined functions. Then you can write a Unit which imports these functions as `external' functions and makes them accessible for your Pascal program. Another thing I did experiments with was a C program which includes the header files and writes out Pascal source for all constants defined in the header. But all these are kludges. The best thing still will be a converter program. What about writing it with GNU Pascal, so we will get a real-world demo program simultaneously? Happy hacking, Peter Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201] maintainer GNU Pascal - http://home.pages.de/~gnu-pascal/ [970125]
On Mon, 31 Mar 1997, Peter Gerwinski wrote:
According to Sven Engelhardt:
I agree. Though IMHO there already exist such tools. Possibly I will do this ... (if there aren't any parser-specialist)
I don't know any parser-specialist. (No, I am not one either.;) I also have never seen any working converter. It would be highly welcome if you would write one!
Greetings, Sorry to intrude, but I think Florian already started such a tool and unless I am mistaken it is available on his developer page.
participants (2)
-
Carl-Eric.Codhre -
Peter Gerwinski