LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 04-01-2004, 09:24 AM   #1
linuxlover1
Member
 
Registered: Jun 2003
Location: UK
Posts: 54

Rep: Reputation: 15
Convert Pascal to C


hello everyone !
I am looking a Pascal to C converter application.
I have found p2c and ptoc but they doesnt work for me.
I want to convert free pascal to C.
Any other ideas ??

Thx in advance !
 
Old 04-01-2004, 09:25 AM   #2
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
In what way don't they work for you?
 
Old 04-01-2004, 09:29 AM   #3
linuxlover1
Member
 
Registered: Jun 2003
Location: UK
Posts: 54

Original Poster
Rep: Reputation: 15
p2c converts the .pas to.c but with many many errors.Lets say that my app is 2000 lines the p2c does 2000 mistakes in tha translation.

PtoC , when i call it, it promts "Can't open configuration file 'ptoc.cfg' " and
"error: can't open input source file: ptoc.pas "
 
Old 04-01-2004, 01:43 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Are you talking plain old wirth, or is the
thing you're trying to convert objectPascal
or Delphi or something the like?

Cheers,
Tink
 
Old 04-02-2004, 05:12 AM   #5
linuxlover1
Member
 
Registered: Jun 2003
Location: UK
Posts: 54

Original Poster
Rep: Reputation: 15
I am just trying to convert a simple Turbo Pascal program.
This program i wrote it with free pascal compiler and i use no libararies , no units....etc just simple pascal commands.
p2c translates the code to C but....gcc finds one error or more errors on each line !
2000 lines ---> 2000 or more errors ! I cant go through the translated code and corrrect them, i havent that much time.

Is there any other Pascal tou C/C++ converter out there exept p2c ??

Last edited by linuxlover1; 04-02-2004 at 05:14 AM.
 
Old 04-02-2004, 05:34 AM   #6
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
ive just tried it and it seems ok, what sort of errors are you getting?
 
Old 04-03-2004, 03:32 AM   #7
linuxlover1
Member
 
Registered: Jun 2003
Location: UK
Posts: 54

Original Poster
Rep: Reputation: 15
The translation seems ok...maybe the gcc is incompatible with the translated c code.
This is an example .
eg.
Pascal code:
Program Hello;
Begin
Writeln('Hello world');
End.
Converted Code (C):
/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */
/* From input file "test.pas" */
#include <p2c/p2c.h>
main(argc, argv)
int argc;
Char *argv[];
{
PASCAL_MAIN(argc, argv);
printf("Hello world\n");
exit(EXIT_SUCCESS);
}
/* End. */

GCC errors:
test.c:5:21: p2c/p2c.h: No such file or directory
test.c: In function `main':
test.c:10: error: syntax error before "Char"
test.c:14: error: `EXIT_SUCCESS' undeclared (first use in this function)
test.c:14: error: (Each undeclared identifier is reported only once
test.c:14: error: for each function it appears in.)

Thx for the help !
 
Old 04-03-2004, 03:46 AM   #8
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
by linuxlover1
test.c:5:21: p2c/p2c.h: No such file or directory

there ya go, the c file produced needs p2c.h and its not there, that means either your include directories are set up wrong or p2c has been installed incorrectly. search your include directories to find p2c.h and the when compiling pass the directory to the compiler, you'll also need to do the same with the library libp2c

on my system p2c is installed in /usr so i compile with

gcc file.c -lp2c

but if your p2c is installed in an odd place say /opt/p2c then you would need to compile with

gcc -I/opt/p2c/include -L/opt/p2c/lib file.c -lp2c
 
Old 04-04-2004, 02:33 PM   #9
linuxlover1
Member
 
Registered: Jun 2003
Location: UK
Posts: 54

Original Poster
Rep: Reputation: 15
thx for the help dude !
 
  


Reply



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
Can someone help me with Pascal? randyriver10 Programming 2 09-29-2005 04:09 PM
pascal howtos? kimx Programming 3 07-18-2005 06:10 AM
C++ and Pascal Compiler LinuxSeeker Linux - Software 2 06-19-2005 12:24 PM
Pascal, and GTK Gerardoj Linux - General 1 09-23-2003 09:34 PM
Pascal for Linux HELP ! linuxlover1 Linux - Software 1 06-22-2003 03:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:25 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration