29-Jun-00 16:10 you wrote:
From: Peter Gerwinski peter@gerwinski.de To: "Nathalie Jarosz" jarosz_n@hotmail.com Subject: Re: beta distribution Date: Wed, 28 Jun 2000 17:41:48 +0200
So I still have some questions... I have tried with a C routine and the pascal unit and program but it doesn't work.
What exactly you done ? It's really trivial task if you know both C and Pascal and thus it's hard to guess where newbie without C knowleadge can fail...
In short: To use functions
extern double foo (double x); extern void bar (void);
Where are these functions and in which form? Is it a C program or do I have to put it in the pascal unit or program?
It's just sample :-) If you have C library with such functions then you can use them from Pascal. Usually such definitions are in .h file but it does not matter if you plan to use them from Pascal.
you write a Pascal unit as follows:
unit FooBar; interface function Foo (x: Real); C; procedure Bar; C; implementation end.
Same questions for this part. Is it a file named FooBar or FooBar.p or something else?...
Better to use name foobar.pas - just like usual Pascal's unit. Perhaps {$L ... } must be added to that file, though: this way C part will be linked automatically when you are using FooBar unit.
Then your program can call the functions:
program Something; uses FooBar; begin Bar; writeln (Foo (42)) end.
I guess that if I manage to define correctly the 2 previous parts, it will be ok...