🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #3475

Linking Turbo (Borland) C into Turbo Pascal program...

#3475
From: George Jetson
Date: Fri, 02 Oct 1992 21:20
42 lines
1898 bytes
I wrote the following Pascal program (X.PAS) :

	Program TestCfunction;

	{$L testc}

	Function mul10(N : Integer) : Integer; external;

	var
		num : Integer;

	begin
		Write('Enter a number: ');
		Readln(num);
		Writeln('Num = ',num);
		Writeln('The result is ',mul10(num));
	end.

and the following C function (TESTC.C) :

	int pascal mul10(int n) { return (10 * n); }

I compiled the C function via "bcc -c testc.c", then tried to compile
the Pascal program via "tpc x".  I got error msg:

	X.PAS(15): Error 51: Invalid PUBLIC definition (TESTC.OBJ).

Then I did "debug testc.obj" and changed the string "_TEXT" to "CODE",
also changing the count byte preceding _TEXT from 5 to 4.  Then I
recompiled the Pascal program and it compiled and runs just fine.

Pretty neat, eh?  How reliable is all of this?

************************************************************************
A note to new readers:  the weasely :-) symbol is frowned upon in this
group.  Any questions, see Phil Gustafson who will gladly rearrange your
diodes for you.
			- From the AFU FAQ -

	- pynq@quads.uchicago.edu, who is still costing the net
	  hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
Technical Details
Message-ID: <1992Oct2.212042.25570@midway.uchicago.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!agate!ames!sun-barr!cs.utexas.edu!usc!sol.ctr.columbia.edu!eff!news.oc.com!spssig.spss.com!uchinews!quads!pynq

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!agate!ames!sun-barr!cs.utexas.edu!usc!sol.ctr.columbia.edu!eff!news.oc.com!spssig.spss.com!uchinews!quads!pynq
From: pynq@quads.uchicago.edu (George Jetson)
Subject: Linking Turbo (Borland) C into Turbo Pascal program...
Message-ID: <1992Oct2.212042.25570@midway.uchicago.edu>
Summary: I'm not sure if this is great or not, but it amuses me.
Sender: news@uchinews.uchicago.edu (News System)
Reply-To: pynq@midway.uchicago.edu
Organization: D. J. Dougherty & Associates
Date: Fri, 2 Oct 1992 21:20:42 GMT
Lines: 42