LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-13-2003, 11:18 AM   #1
chris.hicks
Member
 
Registered: Sep 2003
Location: Newcastle upon Tyne
Distribution: Red Hat 9
Posts: 42

Rep: Reputation: 15
GNU Pascal calls GNU C


I have sorted out GNU C calls GNU Pascal which is in another thread. I have almost got Pascal to call C, but I can't get the variables to transfer properly. I would be grateful for any ideas. Files attached ccall.c, pcallc.p ccall.h and Makefile.

ccall.c
[
#include <stdio.h>
#include "ccall.h"

void world (void)
{
printf("\nHello World\n");
}

void world1 (int *i)
{
printf("In C, I = %i\n",i);
i = 99;
printf("In C, i = %i\n",i);
}
]

ccall.h
[
extern void world(void);
extern void world1(int *i);
]

pcallc.p
[
program pascalcallsC(input,output);

procedure world; external name 'world';
procedure world1(var p : pointer); external name 'world1';

var
i : integer;
p : pointer; {pointer is a Borland extension}
begin
writeln("Hello world from Pascal");
world;
i := 2;
p := @i;
world1(p);
writeln("I = ",i);
end.
]

Makefile:
[
pcallc : pcallc.p ccall.o
gpc -o pcallc pcallc.p ccall.o
ccall.o : ccall.c
gcc -c ccall.c
clean:
rm *.o pcallc
]
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GNU/Linux vs. GNU/OpenSolaris win32sux Linux - Software 5 11-27-2005 10:10 AM
newb question on GNU glibc-2.3.1 upgrade to GNU glibc-2.3.2 clindy528 Slackware 1 11-10-2005 06:49 AM
Debian GNU/kFreeBSD && Debian GNU/NetBSD Arnaud_B Debian 3 06-30-2005 10:39 PM
GNU C calls GNU Pascal? chris.hicks Programming 1 11-13-2003 08:48 AM
GNU c++ Mikeoak83 Linux - Software 3 04-09-2003 03:47 AM


All times are GMT -5. The time now is 05:56 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration