www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/20/19:57:52

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199606202347.AA025954470@relay1.geis.com>
Date: Thu, 20 Jun 96 23:32:00 UTC 0000
To: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: Pascal -> C/C++

Reply to message 8321756    from RKWCVDZ AT RIVIE on 06/20/96  7:40AM


>Hi . Has anyone noticed that under ,dos 7.0 u dont need to use a Dpmi Host.
>Does Dos 7.0 have a Built in Dpmi Host.

Yes, Windows 95's DPMI host.  On a Win95 system, unless you shut down
in DOS mode, you get the buggy Win95 DPMI.  For details, ask Charles
Sandmann.

>Heres A Quick Question . Whats the Best Way to convert all my
>Algorithms(Sorting and Btrees) from Pascal to Djgpp ... Should I rewrite
>all of them from scratch ?

Well, that's what I would do.  I don't trust conversion programs. :)  You
might take note, however, of some of the built in C functions like
qsort(), bsearch(), etc.  They are somewhat complicated to use, but
they accomplish a lot of the basic data manipulation that most users
need without having to worry about writing your own algorithms.  In
most cases, a customized algorithm that you write will be faster
(mostly due to compiler optimizations), however if speed is not your
primary concern it is far easier to use the built in functions.

>Does the fact that the Compiler produce faster code than Bp,mean that the
>Algorithms will be faster.

Depends on a number of things.  But mostly the GNU C (gcc) optimizer is
very good at speeding up code, and AFAIK Pascal wasn't designed
to be a _fast_ language, just an easy one.  :)

>I have a Unit in Pascal that Times the Speed of different Algorithms ,
>whats the best way to convert it to a header File.

Units in Pascal and header files in C are somewhat different in the
way they are used.  In C, header files seldom contain actual code;
they usually just contain function and macro definitions which your
program needs to compile.  The actual code is kept in separate
libraries and/or source files, which get linked to your main program
when it is compiled.  The transition isn't too hard to get used to, but
it might make conversion a bit of a pain.

To be completely truthful, it's perfectly ok to put code in headers,
but it can get very confusing, especially when debugging (the
standard debugging tools for DJGPP can't properly locate code
in header files).  Also, if you ever try to include the header in
multiple source files which are all part of the same program, you
will get linker errors about duplication of symbols and functions.

>Are there any resources on the net for Writing Algorithms in C/C++

Probably lots.  :)  You can even, if you're brave, look in the sources
for some of the library algorithms, like qsort(), for examples.

>Has anyone Noticed that under Dos 7.0 u dont need a Dpmi Host ?

Why, yes, in fact.  We even noticed it the first time you asked.  :)

Lots of luck!

John

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019