Linking Pascal routines into C programs 
Author Message
 Linking Pascal routines into C programs

I've got some legacy metaware Pascal routines that I want to call MS Visual
C (required).   Changes to the method of invoking the routines would be OK,
but I want to avoid changing  any code internal to the routines.  These
routines written as pascal programs without bodies, and the original intent
was to call these routines from assembly.  A typical program containing
callable routines is shown below:

program prog;

    var ...        { I assumed these variables are local to this program}

    procedure X(..); external;
    procedure X(..);
    begin
        ....
    end;

    procedure Y(..); external;
    procedure Y(..);
    begin
        ....
    end;
. { Note the period here with no program begin/end}

I assume that this is metaware's version of a unit at the time the code was
written.  Later metaware came out with Ada-like packages.   Here are my
questions.

1) Is there an existing compiler that can handle this style of code as is?
Metaware no longer offers pascal support.

2) If I did change the program to a unit or equivalent structure (or even if
it could be compiled as is), how would I call it from Visual C.  I have been
able to create C obj files in GCC and successfully link them into Visual C.

Thanks in advance,

Jim.



Thu, 10 Jul 2003 12:59:45 GMT  
 Linking Pascal routines into C programs

Quote:

>I've got some legacy metaware pascal routines that I want to call MS Visual
>C (required).  

Then I think your only option is Delphi.. Other compilers might compile the
code, but probably won't be able to link to VC.


Thu, 10 Jul 2003 18:45:58 GMT  
 Linking Pascal routines into C programs
We've got Delphi 5.0 at work.  It produces its own proprietary (I believe)
object format.  With a -J option, the Delphi compiler additionally produces
OMF formatted objects.  The Visual C++ linker doesn't accept Delphi
generatate OMF, but attemts to run a conversion routine (editbin or 1 other)
to transform these OMFs to COFF format (It fails).  I don't know what flavor
of OMF the Delphi compiler generates, but I have not been able to find a way
to convert Borland OMF to COFF.  I've been told that it is not possible, so
Delphi is a dead end unless I hear something different.

The GCC & GPC compiler both generate COFF.  I've compiled some simple C
routines under GNU, and then linked/run these objects under Visual C++, so I
know there is not an object file format problem.

I believe the problem for now how do I invoke these routines from the C
side, and in what way does the pascal code have to be altered to do this.
Does pascal have any separate compilation similar to a standalone C function
or any other way I can get my foot in the door on this problem.

Jim.



Quote:

> >I've got some legacy metaware pascal routines that I want to call MS
Visual
> >C (required).

> Then I think your only option is Delphi.. Other compilers might compile
the
> code, but probably won't be able to link to VC.



Thu, 10 Jul 2003 23:29:05 GMT  
 Linking Pascal routines into C programs

Quote:

>We've got Delphi 5.0 at work.  It produces its own proprietary (I believe)

>The GCC & GPC compiler both generate COFF.  I've compiled some simple C
>routines under GNU, and then linked/run these objects under Visual C++, so I
>know there is not an object file format problem.

So does FPC iirc. But you can't link directly against C++ there.

Quote:
>I believe the problem for now how do I invoke these routines from the C
>side, and in what way does the pascal code have to be altered to do this.
>Does pascal have any separate compilation similar to a standalone C function
>or any other way I can get my foot in the door on this problem.

Sorry, I don't know GPC internally.


Thu, 10 Jul 2003 23:38:01 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. linking pascal program into c program?!

2. Linking Borlan C function to a Borland Pascal Program

3. Need advice on linking external assembly routines..

4. Link List , use recursive routine to reverse print the node of the list

5. TP6: Compiling 2 programs using common routine

6. Calling main program routine from DLL

7. Help Request: Comm Program Routines

8. Calling Main program routine from DLL under DPMI?

9. Wanted: linear programming routine

10. Linking C in Turbo Pascal or Borland Pascal?

11. Expanded Pascal Links at Pascal Central

12. Expanded Pascal Links at Pascal Central

 

 
Powered by phpBB® Forum Software