home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!mcsun!sunic!liuida!isy!isy!ingemar
- From: ingemar@isy.liu.se (Ingemar Ragnemalm)
- Subject: Re: Think Pascal->C conversion -- advice?
- Message-ID: <ingemar.724696614@isy>
- Sender: news@isy.liu.se (Lord of the News)
- Organization: Dept of EE, University of Linkoping
- References: <1992Dec18.021125.23146@afterlife.ncsc.mil>
- Date: 18 Dec 92 16:36:54 GMT
- Lines: 50
-
-
- mssmith@afterlife.ncsc.mil (M. Scott Smith) writes:
-
- > I'm in the process of converting a large, complex program written with
- >Think Pascal to Think C. I'm pretty fluent in both Pascal and C, and
- >programming the Mac, but I was curious if anyone else has done this and
- >what types of problems they ran into, or what types of things I should be
- >careful about.
-
- Why do you want to do such a thing anyway? If it's speed you are after,
- save your time and write some optimized assembly stuff and link in as
- a library. I mean, Think Pascal code is not slow, as far as I can tell
- it's as fast as Think C.
-
- > I am not the primary author of this code, so I'm not very familiar with
- >it, which puts me at a disadvantage. It's also quite large.
-
- > Some things I see that might be a problem are translating things such as
- >packed arrays of boolean (in Pascal, which I believe are 1-bit in size) yo
- >something equivalent in C. (I can't use integers to represent booleans,
- >because 2 (or 4) bytes is much too large for something that only takes a bit.
- >Think C has a Boolean data type -- but this isn't part of ANSI C, is it?
- >This code needs to be ANSI-C compliant.) That's probably not a major hurdle,
- >but it's little things like that which pop up and make me more cautious.
-
- I hope you are using prototypes, or you will give yourself lots of headaches.
- I usually go the other way around, translating C to Pascal, and Pascal
- nicely catches all references that are different. C without prototypes
- will just crash.
-
- Special types might be a problem in some cases, but usually not. There are
- lots of small things that will make life hard for you, like C's inability
- to hide local procedures from the rest of the program, and it's different
- string format. As long as you are not too dependent on the size of
- variables (due to file formats or resource formats), translating is
- quite possible. (Actually, it's harder to port a Unix program to Think C
- than it is to translate Think C to Think Pascal.) BTW, don't forget to
- declare callback routines (scrollbars, sound manager) as "pascal".
-
- I think translating code snippets or reuseable libraries between the
- languages can be worthwhile, but translating a big program from Think
- Pascal to Think C is a waste of time.
-
- Well, just a few ideas. Take them for what they are worth.
-
- --
- Ingemar Ragnemalm
- Dept. of Electrical Engineering ...!uunet!mcvax!enea!rainier!ingemar
- ..
- University of Linkoping, Sweden ingemar@isy.liu.se
-