how do I call Pascal functions from C? 
Author Message
 how do I call Pascal functions from C?

[comp.lang.c dropped, as they dislike this kind of problems;
 comp.lang.Pascal.misc added, as they can help.
 posted&mailed, as the reader is unlikely to read *.pascal.* groups]

Quote:

> I need to be able to call procedures written in Pascal from my
> main program written in C.  I am using Borland Pascal and Borland C.

> I am converting a DOS app, written in Pascal, to a windows app.
> I am a C programmer, and don't want to muck about in Pascal any
> more than absolutely necessary.

I doubt you won't...

Quote:
> I want to replace the input/output routines with C code, and leave
> the rest intact.

Well, you are in big trouble then...

Pascal, like some (old) languages but unlike C or Ada, have
specials constructions for handling I/O.
And Turbo Pascal/Borland Pascal (TP/BP) converts these to
specials functions calls innerly the system library.

I see 4 solutions:
- you parse all the sources and convert all use of I/O
to calls to special wrappers going to C code: as bulky
as it can be...

- you rewrite the Borland Pascal System library (available
from Borland and written in assembly) to call C functions
instead of DOS: hard, but feaseable; in fact, it could have
been done before, so perhaps you should lurk on the Web...

- only if you use Text files, there is another possibility:
in BP/TP, there is an intermediate level between the
Read/Write calls and the low-level routines; and this level
can be customized by the programmer; moreover, this
"customization" can be done in Pascal, in C or in whatever
language you want.  I will direct you to Borland Pascal
manuals (I don't remember which one precisely: mail me
if you can't locate it);

- you change the Pascal compiler to one which support
Pascal/C mixing directly (this will probably require
rewritings in other parts of the program).

Quote:
> Possible, untried, limited solution:

> I think I could create a DLL with the Pascal routines, and the main
> program entirely in C.

> I don't like this solution, because I'd prefer one runtime file, and
> because I'm sure that there has to be a more general solution.

This addresses the linking problem, and I'm afraid you won't
have any other solution short of changing compiler.

BP procedures can't be used without the System library, which
is only linked by the Borland linker; and this linker won't
support the C run-time library (unless a *major* rewrite here).

So I think the better solution is to keep both languages
(and runtime libraries) separate (or to change compiler).

Hope this helps,

Antoine



Mon, 20 Dec 1999 03:00:00 GMT  
 how do I call Pascal functions from C?



Quote:
>[comp.lang.c dropped, as they dislike this kind of problems;

It's true, the grumpiest, most bad tempered people seem to live in
comp.lang.c
makes me wonder if it's something to do with all that messing about with
pointers etc. that makes them that way

--
TRY=0;/* Andi Carey http://www.amcarey.demon.co.uk*/
if(SUCCEED!=1){do{TRY++;}while(SUCCEED==0 && TRY<3);
if(SUCCEED!=1)POST_TO_comp.lang.c();}



Sat, 25 Dec 1999 03:00:00 GMT  
 how do I call Pascal functions from C?


Quote:

>It's true, the grumpiest, most bad tempered people seem to live in
>comp.lang.c
>makes me wonder if it's something to do with all that messing about with
>pointers etc. that makes them that way

Perhaps.

I personally believe they drink too much coffee while waiting for their
20 lines per day of C code to compile.

--
=\
 *=- R.Moberg, sluuuurp
=/



Sun, 26 Dec 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help With Pascal Iwant to call C function from Pascal

2. calling Turbo Pascal functions from Borland C++ builder

3. how do I call Pascal functions from C?

4. calling c-function from pascal

5. Calling PASCAL procedures/functions from MSVC++

6. Calling C functions from Turbo Pascal?

7. Dll function call

8. Microsoft SQLServer calls BDE-callback function

9. Calling codebase dll functions from another dll

10. Calling Functions in DLL's

11. Calling C functions

12. Calling main function

 

 
Powered by phpBB® Forum Software