user.tex 121 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 1997, by Michael Van Canneyt
  5. %
  6. % The FPC documentation is free text; you can redistribute it and/or
  7. % modify it under the terms of the GNU Library General Public License as
  8. % published by the Free Software Foundation; either version 2 of the
  9. % License, or (at your option) any later version.
  10. %
  11. % The FPC Documentation is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. % Library General Public License for more details.
  15. %
  16. % You should have received a copy of the GNU Library General Public
  17. % License along with the FPC documentation; see the file COPYING.LIB. If not,
  18. % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. % Boston, MA 02111-1307, USA.
  20. %
  21. \documentclass{report}
  22. \usepackage{a4}
  23. \usepackage{html}
  24. \makeindex
  25. \latex{\usepackage{multicol}}
  26. \latex{\usepackage{fpcman}}
  27. \latex{\usepackage{epsfig}}
  28. \html{\input{fpc-html.tex}}
  29. \newcommand{\remark}[1]{\par$\rightarrow$\textbf{#1}\par}
  30. \newcommand{\olabel}[1]{\label{option:#1}}
  31. % We should change this to something better. See \seef etc.
  32. \newcommand{\seeo}[1]{See \ref{option:#1}}
  33. \begin{document}
  34. \title{Free Pascal :\\ Users' manual}
  35. \docdescription{Users' manual for \fpc, version \fpcversion}
  36. \docversion{1.2}
  37. \date{March 1998}
  38. \author{Micha\"el Van Canneyt\\Florian Kl\"ampfl}
  39. \maketitle
  40. \tableofcontents
  41. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  42. % Introduction
  43. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  44. \chapter{Introduction}
  45. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  46. % About this document
  47. \section{About this document}
  48. This is the user's manual for \fpc . It describes the installation and use of
  49. the \fpc compiler on the different supported platforms.
  50. It does not attempt to give an exhaustive list of all supported commands,
  51. nor a definition of the Pascal language. Look at the
  52. \refref for these things.
  53. For a description of the
  54. possibilities and the inner workings of the compiler, see the
  55. \progref. In the appendices of this document you will find lists of
  56. reserved words and compiler error messages (with descriptions).
  57. This document describes the compiler as it is/functions at the time of
  58. writing. Since the compiler is under continuous development, some of the
  59. things described here may be outdated. In case of doubt, consult the
  60. \file{README} files, distributed with the compiler.
  61. The \file{README} files are, in case of conflict with this manual,
  62. authoritative.
  63. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  64. % About the compiler
  65. \section{About the compiler}
  66. \fpc is a 32-bit compiler for the i386 and m68k processors\footnote{Work is being done
  67. on a port to ALPHA Architecture}. Currently, it supports 2 operating systems:
  68. \begin{itemize}
  69. \item \dos
  70. \item \linux
  71. \end{itemize}
  72. and work is in progress to port it to other platforms (notably, \ostwo and
  73. \windowsnt).
  74. \fpc is designed to be, as much as possible, source compatible with
  75. Turbo Pascal 7.0 and Delphi II (although this goal is not yet attained),
  76. but it also enhances these languages with elements like function overloading.
  77. And, unlike these ancestors, it supports multiple platforms.
  78. It also differs from them in the sense that you cannot use compiled units
  79. from one system for the other.
  80. Also, at the time of writing, there is no Integrated Development Environment
  81. (IDE) available for \fpc. This gap will, hopefully, be filled in the future.
  82. \fpc consists of three parts :
  83. \begin{enumerate}
  84. \item The compiler program itself.
  85. \item The Run-Time Library (RTL).
  86. \item Utility programs and units.
  87. \end{enumerate}
  88. Of these you only need the first two, in order to be able to use the compiler.
  89. In this document, we describe the use of the compiler. The RTL is described in the
  90. \refref.
  91. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  92. % Getting more information.
  93. \section{Getting more information.}
  94. If the documentation doesn't give an answer to your questions,
  95. you can obtain more information on the Internet, on the following addresses:
  96. \begin{itemize}
  97. \item
  98. \htmladdnormallink{http://tfdec1.fys.kuleuven.ac.be/\~{}michael/fpc/fpc.html}
  99. {http://tfdec1.fys.kuleuven.ac.be/\~{}michael/fpc/fpc.html} contains information
  100. on the \linux port of the compiler. It contains also useful mail addresses and
  101. links to other places.
  102. \item
  103. \htmladdnormallink{http://www.brain.uni-freiburg.de/\~{}klaus/fpc/fpc.html}
  104. {http://www.brain.uni-freiburg.de/\~{}klaus/fpc/fpc.html} is the main \fpc information site.
  105. It also contains the instructions for inscribing to the \textit{mailing-list},
  106. another useful source of information.
  107. \end{itemize}
  108. Both places can be used to download the \fpc distribution, although you can
  109. probably find them on other places also.
  110. Finally, if you think something should be added to this manual
  111. (entirely possible), please do not hesitate and contact me at
  112. \htmladdnormallink{[email protected]}{mailto:[email protected]}
  113. .
  114. Let's get on with something useful.
  115. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  116. % Installation
  117. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  118. \chapter{Installing the compiler}
  119. \label{ch:Installation}
  120. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  121. % Before Installation : Requirements
  122. \section{Before Installation : Requirements}
  123. %
  124. % System requirements
  125. %
  126. \subsection{System requirements}
  127. The compiler needs at least the following hardware:
  128. \begin{enumerate}
  129. \item An I386 or higher processor. A coprocessor is not required, although it
  130. will slow down your program's performance if you do floating point calculations.
  131. \item 2 Mb of free memory. Under \dos, if you use DPMI memory management,
  132. such as under Windows, you will need at least 8 Mb.
  133. \item At least 500 Kb. free disk space.
  134. \end{enumerate}
  135. %
  136. %
  137. % Software requirements
  138. \subsection{Software requirements}
  139. \subsubsection{Under DOS}
  140. The \dos distribution contains all the files you need to run the compiler
  141. and compile pascal programs.
  142. \subsubsection{Under Linux}
  143. Under \linux you need to have the following programs installed :
  144. \begin{enumerate}
  145. \item \gnu \file{as}, the \gnu assembler.
  146. \item \gnu \file{ld}, the \gnu linker.
  147. \item Optionally (but highly recommended) : \gnu \file{make}. For easy
  148. recompiling of the compiler and Run-Time Library, this is needed.
  149. \end{enumerate}
  150. Other than that, \fpc should run on almost any I386 \linux system.
  151. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  152. % Installing the compiler.
  153. \section{Installing the compiler.}
  154. The installation of \fpc is easy, but is platform-dependent.
  155. We discuss the process for each platform separately.
  156. %
  157. %
  158. % Installing under DOS
  159. \subsection{Installing under DOS}
  160. \subsubsection{Mandatory installation steps.}
  161. First, you must get the latest distribution files of \fpc. They come as zip
  162. files, which you must unzip first. The distribution zip file contains an
  163. installation program \file{INSTALL.EXE}. You must run this program to install
  164. the compiler.
  165. \html{
  166. The screen of the installation program looks like this:
  167. \htmladdimg{../pics/install.gif}
  168. }
  169. \latex{
  170. The screen of the installation program looks like figure \ref{fig:install}.
  171. \begin{figure}
  172. \caption{The \dos install program screen.}
  173. \label{fig:install}
  174. \epsfig{file=pics/install.eps,width=\textwidth}
  175. \end{figure}
  176. }
  177. The program allows you to select:
  178. \begin{itemize}
  179. \item What components you wish to install. (e.g do you want the sources or
  180. not, do you want docs or not) Items that you didn't download will not
  181. be enabled, i.e. you can't select them.
  182. \item Where you want to install (the default location is \verb|C:\PP|).
  183. \end{itemize}
  184. The installation program generates a batch file which sets some environment
  185. variables : \verb|SET_PP.BAT|. This file is located in the directory where
  186. you installed \fpc. The installation program doesn't modify the
  187. \file{AUTOEXEC.BAT}, since many people (including the authors of \fpc)
  188. don't like this.
  189. You can choose to insert a call to this batch file in your \file{AUTOEXEC.BAT}
  190. file, like this :
  191. \begin{verbatim}
  192. CALL C:\PP\SET_PP.BAT
  193. \end{verbatim}
  194. (This is assuming that you installed \fpc in the default location.)
  195. In order to run \fpc from any directory on your system, you must extend
  196. your path variable to contain the \verb|C:\PP\BIN| directory.
  197. You can choose to do this in your \file{AUTOEXEC.BAT} file, but you can also
  198. insert a statement in the \verb|SET_PP.BAT| file. Whatever the location you
  199. choose, It should look something like this :
  200. \begin{verbatim}
  201. SET PATH=%PATH%;C:\PP\BIN
  202. \end{verbatim}
  203. (Again, assuming that you installed in the default location).
  204. If you want to use the graphic drivers you must modify the
  205. environment variable \var{GO32}. Instructions for doing this can be found
  206. in the documentation of the Graph unit, at the \var{InitGraph} procedure.
  207. \subsubsection{Optional Installation: The coprocessor emulation}
  208. For people who have an older CPU type, without math coprocessor (i387)
  209. it is necessary to install a coprocessor emulation, since \fpc uses the
  210. coprocessor to do all floating point operations.
  211. The installation of the coprocessor emulation is handled by the
  212. installation program (\file{INSTALL.EXE}). However,
  213. the installation program has currently a bug: If you select the
  214. coprocessor emulation the program ignores this and you must do
  215. this by hand. You should change the \var{GO32} environment variable in
  216. the \verb|SET_PP.BAT| file, as follows:
  217. \begin{verbatim}
  218. SET GO32=emu C:\PP\DRIVERS\EMU387
  219. \end{verbatim}
  220. %
  221. % Installing under Linux
  222. %
  223. \subsection{Installing under Linux}
  224. \subsubsection{Mandatory installation steps.}
  225. The \linux distribution of \fpc comes in three forms:
  226. \begin{itemize}
  227. \item a \file{tar.gz} version,
  228. \item a \file{.rpm} (Red Hat Package Manager) version, and
  229. \item a \file{.deb} (debian) version.
  230. \end{itemize}
  231. All of these packages contain a \var{ELF} version of the compiler binaries and
  232. units. the older \var{aout} binaries are no longer distributed, although you
  233. still can use the comiler on an \var{aout} system if you recompile it.
  234. If you use the \file{.rpm} format, installation is limited to
  235. \begin{verbatim}
  236. rpm -i fpc-pascal-XXX.rpm
  237. \end{verbatim}
  238. (\var{XXX} is the version number of the \file{.rpm} file)
  239. If you use debian, installation is limited to
  240. \begin{verbatim}
  241. dpkg -i fpc-XXX.deb
  242. \end{verbatim}
  243. Here again, \var{XXX} is the version number of the \file{.deb} file.
  244. You need root access to install these packages. The \file{.tar} file
  245. allows you to do an installation if you don't have root permissions.
  246. When downloading the \var{.tar} file, installation is more interactive:
  247. This means that you should first untar the file, in some directory where
  248. you have write permission, using the following command:
  249. \begin{verbatim}
  250. tar -xvf fpc.tar
  251. \end{verbatim}
  252. We supposed here that you downloaded the file \file{fpc.tar} somewhere
  253. from the Internet. (The real filename will have some version number in it,
  254. which we omit here for clarity.)
  255. When the file is untarred, you will be left with more archive files, and
  256. an install program: an installation shell script.
  257. To install \fpc, all that you need to do now is give the following command:
  258. \begin{verbatim}
  259. ./install.sh
  260. \end{verbatim}
  261. And then you must answer some questions. They're very simple, they're
  262. mainly concerned with 2 things :
  263. \begin{enumerate}
  264. \item Places where you can install different things.
  265. \item Deciding if you want to install certain components (such as sources
  266. and demo programs).
  267. \end{enumerate}
  268. If you run the installation script as the \var{root} user, you can just accept all installation
  269. defaults. If you don't run as \var{root}, you must take care to supply the
  270. installation program with directory names where you have write permission,
  271. as it will attempt to create the directories you specify.
  272. In principle, you can install it wherever you want, though.
  273. At the end of installation, the installation program will generate a
  274. configuration file for the \fpc compiler which reflects the settings
  275. that you chose. It will install this file in the \file{/etc} directory, (if
  276. you are not installing as \var{root}, this will fail), and in the
  277. directory where you installed the libraries.
  278. If you want the \fpc compiler to use this configuration file, it must be
  279. present in \file{/etc}, or you can set the environment variable
  280. \var{PPC\_CONFIG\_PATH}. Under \file{csh}, you can do this by adding a
  281. \begin{verbatim}
  282. setenv PPC_CONFIG_PATH /usr/lib/ppc/0.99.1
  283. \end{verbatim}
  284. line to your \file{.login} file in your home directory.
  285. (see also the next section)
  286. \subsubsection{Optional configuration steps}
  287. You may wish to set some environment variables. The \linux version of \fpc
  288. recognizes the following variables :
  289. \begin{itemize}
  290. \item \verb|PPC_EXEC_PATH| contains the directory where '\file{as}' and
  291. '\file{ld}' are. (default \file{/usr/bin})
  292. \item \verb|PPC_GCCLIB_PATH| contains the directory where \file{libgcc.a} is (no default)
  293. \item \verb|PPC_CONFIG_PATH| specifies an alternate path to find
  294. \file{ppc386.cfg} (default \file{/etc})
  295. \item \verb|PPC_ERROR_FILE| specifies the path and name of the error-definition file.
  296. (default \file{/usr/lib/ppc/errorE.msg})
  297. \end{itemize}
  298. These locations are, however, set in the sample configuration file which is
  299. built at the end of the installation process, except for the
  300. \verb|PPC_CONFIG_PATH| variable, which you must set if you didn't install
  301. things in the default places.
  302. \subsubsection{finally}
  303. Also distributed in \fpc is a README file. It contains the latest
  304. instructions for installing \fpc, and should always be read first.
  305. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  306. % Testing the compiler
  307. \section{Testing the compiler}
  308. After the installation is completed and the environment variables are
  309. set as described above, your first program can be compiled.
  310. Included in the \fpc distribution are some demonstration programs,
  311. showing what the compiler can do.
  312. You can test if the compiler functions correctly by trying to compile
  313. these programs.
  314. The compiler is called
  315. \begin{itemize}
  316. \item \file{PPC386.EXE} under \dos, and
  317. \item \file{ppc386} under \linux
  318. \end{itemize}
  319. To compile a program (e.g \verb|demo\hello.pp|) simply type :
  320. \begin{verbatim}
  321. ppc386 hello
  322. \end{verbatim}
  323. at the command prompt.
  324. If you got no error messages, the compiler has generated an executable
  325. called \file{hello} (no extension) under \linux, and a file \file{hello.exe}
  326. under \dos.
  327. To execute the program, simply type :
  328. \begin{verbatim}
  329. hello
  330. \end{verbatim}
  331. If all went well, you should see the following friendly greeting:
  332. \begin{verbatim}
  333. Hello world
  334. \end{verbatim}
  335. In the \dos case, this friendly greeting may be preceded by some ugly
  336. message from the \file{GO32} extender program. This unfriendly behavior can
  337. be switched off by setting the \file{GO32} environment variable.
  338. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  339. % Usage
  340. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  341. \chapter{Compiler usage}
  342. \label{ch:Usage}
  343. Here we describe the essentials to compile a program and a unit.
  344. We also describe how to make a stand-alone executable of the
  345. compiled program under \dos. For more advanced uses of the compiler,
  346. see the section on configuring the compiler, and the
  347. \progref.
  348. The examples in this section suppose that you have a \file{ppc386.cfg} which
  349. is set up correctly, and which contains at least the path setting for the
  350. RTL units. In principle this file is generated by the installation program.
  351. You may have to check that it is in the correct place (see section
  352. \ref{se:config_file} for more information on this).
  353. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  354. % Compiling a program
  355. \section{Compiling a program}
  356. Compiling a program is very simple. Assuming that you have a program source
  357. in the file \file{prog.pp}, you can compile this with the following command:
  358. \begin{verbatim}
  359. ppc386 [options] prog.pp
  360. \end{verbatim}
  361. The square brackets [] indicate that what is between them is optional.
  362. If your program file has the \file{.pp} or \file{.pas} extension,
  363. you can omit this on the command line, e.g. in the previous example you
  364. could have typed:
  365. \begin{verbatim}
  366. ppc386 [options] prog
  367. \end{verbatim}
  368. If all went well, the compiler will produce an executable, or, for version 1
  369. of the \dos extender, a file which can be converted to an executable.
  370. Under \linux and version 2 of the \dos extender, the file you obtained is
  371. the executable. You can execute it straight away, you don't need to do
  372. anything else. Under \dos,
  373. additional processing is required. See the section on creating an
  374. executable.
  375. You will notice that there is also anothe file in your directory, with
  376. extensions \file{.o}. This contains, the object file for your program.
  377. If you compiled a program, you can delete the object file (\file{.o}),
  378. but not if you compiled a unit.
  379. Then the object file contains the code of the unit, and will be
  380. linked in any program that uses the unit you compiled, so you shpuldn't
  381. remove it.
  382. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  383. % Compiling a unit
  384. \section{Compiling a unit}
  385. Compiling a unit is not essentially different from compiling a program.
  386. The difference is mainly that the linker isn't called in this case.
  387. To compile a unit in the file \file{foo.pp}, just type :
  388. \begin{verbatim}
  389. ppc386 foo
  390. \end{verbatim}
  391. Recall the remark about file extensions in the previous section.
  392. When all went well, you will be left with 2 (two) unit files:
  393. \begin{enumerate}
  394. \item \file{foo.ppu} This is the file describing the unit you just
  395. compiled.
  396. \item \file{foo.o} This file contains the actual code of the unit.
  397. This file will eventually end up in the executables.
  398. \end{enumerate}
  399. Both files are needed if you plan to use the unit for some programs.
  400. So don't delete them. If you want to distribute the unit, you must
  401. provide both the \file{.ppu} and \file{.o} file. One is useless without the
  402. other.
  403. {\em Remark:}
  404. Under \linux, a unit source file {\em must} have a lowercase filename.
  405. Since Pascal is case independent, you can specify the names of units in the
  406. \var{uses} clause in either case. To get a unique filename, the \fpc compiler
  407. changes the name of the unit to all lowercase when looking for unit files.
  408. The compiler produces lowercase files, so your unit will be found, even if
  409. your source file has uppercase letters in it. Only when the compiler tries to
  410. recompile the unit, it will not find your source because of the uppercase
  411. letters.
  412. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  413. % Creating an executable for GO32V1, PMODE/DJ targets
  414. \section{Creating an executable for GO32V1 and PMODE/DJ targets}
  415. This section applies only to \dos users. \linux users can skip this
  416. section (unless they're cross-compiling)
  417. %
  418. % GO32V1
  419. %
  420. \subsection{GO32V1}
  421. When compiling under \dos, GO32V2 is the default target. However, if you use
  422. go32V1 (using the \var{-TGO32V1} switch), the
  423. compilation process leaves you with a file which you cannot execute right away.
  424. There are 2 things you can do when compiling has finished.
  425. The first thing is to use the \dos extender from D.J. Delorie to execute
  426. your program :
  427. \begin{verbatim}
  428. go32 prog
  429. \end{verbatim}
  430. This is fine for testing, but if you want to use a program regularly, it
  431. would be easier if you could just type the program name, i.e.
  432. \begin{verbatim}
  433. prog
  434. \end{verbatim}
  435. This can be accomplished by making a \dos executable of your compiled program.
  436. There two ways to create a \dos executable (under \dos only):
  437. \begin{enumerate}
  438. \item if the \file{GO32.EXE} is already
  439. installed on the computers where the program should run, you must
  440. only copy a program called \file{STUB.EXE} at the begin of
  441. the AOUT file. This is accomplished with the \file{AOUT2EXE.EXE} program.
  442. which comes with the compiler:
  443. \begin{verbatim}
  444. AOUT2EXE PROG
  445. \end{verbatim}
  446. and you get a \dos executable which loads the \file{GO32.EXE} automatically.
  447. the \file{GO32.EXE} executable must be in current directory or be
  448. in a directory in the \var{PATH} variable.
  449. \item
  450. The second way to create a \dos executable is to put
  451. \file{GO32.EXE} at the beginning of the \file{AOUT} file. To do this, at the
  452. command prompt, type :
  453. \begin{verbatim}
  454. COPY /B GO32.EXE+PROG PROG.EXE
  455. \end{verbatim}
  456. (assuming \fpc created a file called \file{PROG}, of course.)
  457. This becomes then a stand-alone executable for \dos, which doesn't need the
  458. \file{GO32.EXE} on the machine where it should run.
  459. \end{enumerate}
  460. %
  461. %
  462. % PMODE/DJ
  463. \subsection{PMODE/DJ}
  464. You can also use the PMODE/DJ extender to run your \fpc applications.
  465. To make an executable which works with the PMODE extender, you can simply
  466. create an GO32V2 executable (the default), and then convert it to a PMODE
  467. executable with the following two extra commands:
  468. \begin{enumerate}
  469. \item First, strip the GO32V2 header of the executable:
  470. \begin{verbatim}
  471. EXE2COFF PROG.EXE
  472. \end{verbatim}
  473. (we suppose that \file{PROG.EXE} is the program generated by the compilation
  474. process.
  475. \item Secondly, add the PMODE stub:
  476. \begin{verbatim}
  477. COPY /B PMODSTUB.EXE+PROG PROG.EXE
  478. \end{verbatim}
  479. If the \file{PMODSTUB.EXE} file isn't in your local directory, you need to
  480. supply the whole path to it.
  481. \end{enumerate}
  482. That's it. No additional steps are needed to create a PMODE extender
  483. executable.
  484. Be aware, though, that the PMODE extender doesn't support virtual memory, so
  485. if you're short on memory, you may run unto trouble. Also, officially there
  486. is not support for the PMODE/DJ extender. It just happens that the compiler
  487. and some of the programs it generates, run under this extender too.
  488. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  489. % Reducing the size of your program
  490. \section{Reducing the size of your program}
  491. When you created your program, it is possible to reduce its size. This
  492. is possible, because the compiler leaves a lot of information in the
  493. program which, strictly speaking, isn't required for the execution of
  494. it. The surplus of information can be removed with a small program
  495. called \file{strip}. It comes with the \var{GO32} development
  496. environment under \dos, and is standard on \linux machines where you can
  497. do development. The usage is simple. Just type
  498. \begin{verbatim}
  499. strip prog
  500. \end{verbatim}
  501. On the command line, and the \file{strip} program will remove all unnecessary
  502. information from your program. This can lead to size reductions of up to
  503. 30 \%.
  504. You can use the \var{-Xs} switch to let the compiler do this stripping
  505. automatically.
  506. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  507. % Problems
  508. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  509. \chapter{Compiling problems}
  510. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  511. % General problems
  512. \section{General problems}
  513. \begin{itemize}
  514. \item \textbf{IO-error -2 at ...} : Under \linux you can get this message at
  515. compiler startup. It means typically that the compiler doesn't find the
  516. error definitions file. You can correct this mistake with the \var{-Fr}
  517. option under \linux. (\seeo{Fr})
  518. \item \textbf {Error : File not found : xxx} This typically happens when
  519. your unit path isn't set correctly. Remember that the compiler looks for
  520. units only in the current directory, and in the directory where the compiler
  521. itself is. If you want it to look somewhere else too, you must explicitly
  522. tell it to do so using the \var{-Up} option (\seeo{Up}).
  523. \end{itemize}
  524. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  525. % Problems you may encounter under DOS
  526. \section{Problems you may encounter under DOS}
  527. \begin{itemize}
  528. \item \textbf{No space in environment}.\\
  529. An error message like this can occur, if you call
  530. \verb|SET_PP.BAT| in the \file{AUTOEXEC.BAT}.\\
  531. To solve this problem, you must extend your environment memory.
  532. To do this, search a line in the \file{CONFIG.SYS} like
  533. \begin{verbatim}
  534. SHELL=C:\DOS\COMMAND.COM
  535. \end{verbatim}
  536. and change it to the following:
  537. \begin{verbatim}
  538. SHELL=C:\DOS\COMMAND.COM /E:1024
  539. \end{verbatim}
  540. You may just need to specify a higher value, if this parameter is already set.
  541. \item \textbf{ Coprocessor missing}\\
  542. If the compiler writes
  543. a message that there is no coprocessor, install
  544. the coprocessor emulation.
  545. \item \textbf{Not enough DPMI memory}\\
  546. If you want to use the compiler with \var{DPMI} you must have at least
  547. 7-8 MB free \var{DPMI} memory.
  548. \end{itemize}
  549. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  550. % Configuration.
  551. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  552. \chapter{Compiler configuration}
  553. \label{ch:CompilerConfiguration}
  554. The output of the compiler can be controlled in many ways. This can be done
  555. essentially in two distinct ways:
  556. \begin{itemize}
  557. \item Using command-line options.
  558. \item Using the configuration file: \file{ppc386.cfg}.
  559. \end{itemize}
  560. The compiler first reads the configuration file. Only then the command line
  561. options are checked. This creates the possibility to set some basic options
  562. in the configuration file, and at the same time you can still set some
  563. specific options when compiling some unit or program. First we list the
  564. command line options, and then we explain how to specify the command
  565. line options in the configuration file. When reading this, keep in mind
  566. that the options are case sensitive. While this is customary for \linux, it
  567. isn't under \dos.
  568. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  569. % Using the command-line options
  570. \section{Using the command-line options}
  571. The available options are listed by category:
  572. %
  573. % General options
  574. %
  575. \subsection{General options}
  576. \begin{description}
  577. \item[-h] if you specify this option, the compiler outputs a list of all options,
  578. and exits after that.
  579. \olabel{h}
  580. \item[-?] idem as \var{-h}.
  581. \item[-i] This option tells the compiler to print the copyright information.
  582. \olabel{i}
  583. \item[-l] This option tells the compiler to print the \fpc logo on standard
  584. output. It also gives you the \fpc version number.
  585. \olabel{l}
  586. \item[-Lx] Set the language the compiler uses for its messages.
  587. \olabel{L}
  588. \var{x} can be one of the following:
  589. \begin{itemize}
  590. \item \textbf{D} : Use German.
  591. \item \textbf{E} : Use English.
  592. \end{itemize}
  593. \item [-n] Tells the compiler not to read the configuration file.
  594. \olabel{n}
  595. \end{description}
  596. %
  597. % Options for getting feedback
  598. %
  599. \subsection{Options for getting feedback}
  600. \begin{description}
  601. \item[-vxxx] Be verbose. \var{xxx} is a combination of the following :
  602. \olabel{v}
  603. \begin{itemize}
  604. \item \var{e} : Tells the compiler to show only errors. This option is on by default.
  605. \item \var{i} : Tells the compiler to show some general information.
  606. \item \var{w} : Tells the compiler to issue warnings.
  607. \item \var{n} : Tells the compiler to issue notes.
  608. \item \var{h} : Tells the compiler to issue hints.
  609. \item \var{l} : Tells the compiler to show the line numbers as it processes a
  610. file. Numbers are shown per 100.
  611. \item \var{u} : Tells the compiler to print the names of the files it opens.
  612. \item \var{t} : Tells the compiler to print the names of the files it tries
  613. to open.
  614. \item \var{p} : Tells the compiler to print the names of procedures and
  615. functions as it is processing them.
  616. \item \var{c} : Tells the compiler to warn you when it processes a
  617. conditional.
  618. \item \var{m} : Tells the compiler to write which macros are defined.
  619. \item \var{d} : Tells the compiler to write other debugging info.
  620. \item \var{a} : Tells the compiler to write all possible info. (this is the
  621. same as spcifying all options)
  622. \item \var{0} : Tells the compiler to write no messages. This is useful when
  623. you want to override the default setting in the configuration file.
  624. \end{itemize}
  625. \end{description}
  626. %
  627. % Options concerning files and directories
  628. %
  629. \subsection{Options concerning files and directories}
  630. \begin{description}
  631. \item [-exxx] (\linux only) \file{xxx} specifies the directory where the
  632. compiler can find the executables \file{as} (the assembler) and \file{ld} (the
  633. compiler).
  634. \olabel{e}
  635. \item [-Fexxx] This option tells the compiler to write errors, etc. to
  636. the file in \file{xxx}.
  637. \olabel{Fe}
  638. \item [-Fgxxx] (\linux only) \file{xxx} specifies the path where the compiler
  639. can find the \gnu C library.
  640. \olabel{Fg}
  641. \item [-Fixxx] adds \var{xxx} to the path where the compiler searches for
  642. its include files.
  643. \olabel{Fi}
  644. \item [-Flxxx] Adds \var{xxx} to the library searching path, and is passed
  645. to the linker.
  646. \olabel{Fl}
  647. \item [-Frxxx] (\linux only) \file{xxx} specifies the path where the
  648. compiler can find the error-definitions file.
  649. \olabel{Fr}
  650. \item [-Fuxxx] Idem as \var{-Up}.
  651. \olabel{Fu}
  652. \item [-P] uses pipes instead of files when assembling. This may speed up
  653. the compiler on \ostwo and \linux. Only with assemblers (such as \gnu
  654. \file{as}) that support piping..
  655. \item [-Upxxx] \olabel{Up} Tells the compiler to add \file{xxx} to the path where to find
  656. units. \\
  657. By default, the compiler only searches for units in the current directory
  658. and the directory where the compiler itself resides. This option tells the
  659. compiler also to look in the directory \file{xxx}.
  660. \end{description}
  661. % Options controlling the kind of output.
  662. \subsection{Options controlling the kind of output.}
  663. for more information on these options, see also \progref
  664. \begin{description}
  665. \item [-a] \olabel{a} Tells the compiler not to delete the assembler file.
  666. This also counts for the (possibly) generated batch script.
  667. \item [-Axxx] \olabel{A}specifies what kind of assembler should be generated . Here
  668. \var{xxx} is one of the following :
  669. \begin{itemize}
  670. \item \textbf{att} : AT\&T assembler.
  671. \item \textbf{o} : A unix .o (object) file.
  672. \item \textbf{obj} : A OMF file for using the NASM assembler.
  673. \item \textbf{nasm} : a coff file using the NASM assembler.
  674. \item \textbf{masm} : An assembler file for the Microsoft/Borland/Watcom assembler.
  675. \end{itemize}
  676. \item [-CD] Force dynamic linking.
  677. \item [-Chxxx] \olabel {Ch} Reserves \var{xxx} bytes heap.
  678. \item [-Ci] \olabel{Ci} Generate Input/output checking code.
  679. \item [-Cn] \olabel{Cn} Omit the linking stage.
  680. \item [-Co] \olabel{Co} Generate Integer overflow checking code.
  681. \item [-Cr] \olabel{Cr} Generate Range checking code.
  682. \item [-Csxxx] \olabel{Cs} Set stack size to \var{xxx}. (\ostwo only).
  683. \item [CS] \olabel{CS} Statically link your program/unit.
  684. \item [-Ct] \olabel{Ct} generate stack checking code.
  685. \item [-dxxx] \olabel{d} Define the symbol name \var{xxx}. This can be used
  686. to conditionally compile parts of your code.
  687. \item {-E} \olabel{E} Same as \var{-Cn}.
  688. \item [-g] \olabel{g} Generate debugging information for debugging with
  689. \file{gdb}.
  690. \item [-gp] \olabel{gp} Generate profiler code for \file{gprof}.
  691. \item[-On] \olabel{O} optimize the compiler's output; \var{n} can have one
  692. of the following values :
  693. \begin{description}
  694. \item[a] simple optimizations
  695. \item[g] optimize for size
  696. \item[G] optimize for time
  697. \item[x] optimize maximum
  698. \item[z] uncertain optimizations
  699. \item[2] optimize for Pentium II (tm)
  700. \item[3] optimize for i386
  701. \item[4] optimize for i486
  702. \item[5] optimize for Pentium (tm)
  703. \item[6] optimizations for PentiumPro (tm)
  704. \end{description}
  705. The exact effect of these effects can be found in the appendices of the
  706. \progref.
  707. \item [-oxxx] Tells the compiler to use \var{xxx} as the name of the output
  708. file (executable). Only with programs.
  709. \item [-pg] Tells the compiler to issue code for profiling support.
  710. \item [-s] \olabel{s} Tells the compiler not to call the assembler and linker.
  711. Instead, the compiler writes a script, \file{PPAS.BAT} under \dos, or
  712. \file{ppas.sh} under \linux, which can then be executed to produce an
  713. executable.
  714. \item[-Txxx] \olabel{T}Specifies the target operating system. \var{xxx} can be one of
  715. the following:
  716. \begin{itemize}
  717. \item \textbf{DOS} : \dos and the DJ DELORIE extender.
  718. \item \textbf{OS2} : OS/2 (2.x) (this is still under development).
  719. \item \textbf{LINUX} : \linux.
  720. \item \textbf{WIN32} : Windows 32 bit (this is still under development).
  721. \item \textbf{GO32V2} : \dos and version 2 of the DJ DELORIE extender.
  722. \end{itemize}
  723. \item [-Uld] \olabel{Uld} make dynamic library from unit.
  724. \item [-Uls] \olabel{Uls} make static library from unit.
  725. \item [-uxxx] \olabel{U} Undefine symbol \var{xxx}.
  726. \item [-Xx] \olabel{X} executable options. This tells the compiler what
  727. kind of \linux executable should be generated. the parameter \var{x}
  728. can be one of the following:
  729. \begin{itemize}
  730. % \item \textbf{e} : (\linux only) Create an \file{ELF} executable (default).
  731. \item \textbf{c} : (\linux only) Link with the C library. You should only use this when
  732. you start to port \fpc to another operating system.
  733. \item \textbf{s} : (\dos only) Strip the symbols from the executable.
  734. \end{itemize}
  735. \end{description}
  736. %
  737. %
  738. % Options concerning the sources (language options)
  739. \subsection{Options concerning the sources (language options)}
  740. for more information on these options, see also \progref
  741. \begin{description}
  742. \item [-Rxxx] \olabel{R} Specifies what assembler you use in your \var{asm} assembler code
  743. blocks. Here \var{xxx} is one of the following:
  744. \begin{description}
  745. \item [att\ ] \var{asm} blocks contain AT\&T assembler.
  746. \item [intel] \var{asm} blocks contain Intel assembler.
  747. \item [direct] \var{asm} blocks should be copied as-is in the assembler
  748. file.
  749. \end{description}
  750. \item [-S2] \olabel{Stwo} Switch on Delphi 2 extensions.
  751. \item [-Sc] \olabel{Sc} Support C-style operators, i.e. \var{*=, +=, /= and
  752. -=}.
  753. \item [-Se] \olabel{Se} The compiler stops after the first error. Normally,
  754. the compiler tries to continue compiling after an error, until 50 errors are
  755. reached, or a fatal error is reachd, and then it stops. With this switch,
  756. the compiler will stop after the first error.
  757. \item [-Sg] \olabel{Sg} Support the \var{label} and \var{goto} commands.
  758. \item [-Si] \olabel{Si} Support \var{C++} style INLINE.
  759. \item [-Sm] \olabel{Sm} Support C-style macros.
  760. \item [-So] \olabel{So} Try to be Borland TP compatible (no function
  761. overloading etc.).
  762. \item [-Ss] \olabel{Ss} The name of constructors must be \var{init}, and the
  763. name of destructors should be \var{done}.
  764. \item [-St] \olabel{St} Allow the \var{static} keyword in objects.
  765. \item [-Un] \olabel{Un} Do not check the unit name. (Normally, the unit name
  766. is the same as the filename. This option allows both to be different.)
  767. \item [-Us] \olabel{Us} Compile a system unit. This option causes the
  768. compiler to define only some very basic types.
  769. \end{description}
  770. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  771. % Using the configuration file
  772. \section{Using the configuration file}
  773. \label{se:config_file}
  774. Using the configuration file \file{ppc386.cfg} is an alternative to command
  775. line options. When a configuration file is found, it is read, and the lines
  776. in it are treated like you typed them on the command line. They are treated
  777. before the options that you type on the command line.
  778. You can specify comments in the configuration file with the \var{\#} sign.
  779. Everything from the \var{\#} on will be ignored.
  780. The compiler looks for the \file{ppc386.cfg} file in the following places :
  781. \begin{itemize}
  782. \item Under \linux
  783. \begin{enumerate}
  784. \item The current directory.
  785. \item In your home directory, it looks for \file{.ppc386.cfg}.
  786. \item The directory specified in the environment variable
  787. \var{PPC\_CONFIG\_PATH}, and if it's not set under \file{/etc}.
  788. \end{enumerate}
  789. \item Under all other OSes:
  790. \begin{enumerate}
  791. \item The current directory.
  792. \item If it is set, the directory specified in the environment variable.
  793. \var{PPC\_CONFIG\_PATH}.
  794. \item The directory where the compiler is.
  795. \end{enumerate}
  796. \end{itemize}
  797. When the compiler has finished reading the configuration file, it continues
  798. to treat the command line options.
  799. One of the command-line options allows you to specify a second configuration
  800. file: Specifying \file{@foo} on the command line will open file \file{foo},
  801. and read further options from there. When the compiler has finished reading
  802. this file, it continues to process the command line.
  803. The configuration file allows some kind of preprocessing. It understands the
  804. following directives, which you should place on the first column of a line :
  805. \begin{description}
  806. \item [\#IFDEF]
  807. \item [\#IFNDEF]
  808. \item [\#ELSE]
  809. \item [\#ENDIF]
  810. \item [\#DEFINE]
  811. \item [\#UNDEF]
  812. \item [\#WRITE]
  813. \item [\#INCLUDE]
  814. \item [\#SECTION]
  815. \end{description}
  816. They work the same way as their \{\$...\} counterparts in Pascal.
  817. What follows is a description of the different directives.
  818. \subsection{\#IFDEF}
  819. Syntax:
  820. \begin{verbatim}
  821. #IFDEF name
  822. \end{verbatim}
  823. Lines following \var{\#IFDEF} are skipped read if the keyword \var{name}
  824. following it is not defined.
  825. They are read until the keywords \var{\#ELSE} or \var{\#ENDIF} are
  826. encountered, after which normal processing is resumed.
  827. Example :
  828. \begin{verbatim}
  829. #IFDEF VER0_99_5
  830. -Up/usr/lib/fpc/0.99.5/linuxunits
  831. #ENDIF
  832. \end{verbatim}
  833. In the above example, \file{/usr/lib/fpc/0.99.5/linuxunits} will be added to
  834. the path if you're compiling with version 0.99.5 of the compiler.
  835. \subsection{\#IFNDEF}
  836. Syntax:
  837. \begin{verbatim}
  838. #IFNDEF name
  839. \end{verbatim}
  840. Lines following \var{\#IFDEF} are skipped read if the keyword \var{name}
  841. following it is defined.
  842. They are read until the keywords \var{\#ELSE} or \var{\#ENDIF} are
  843. encountered, after which normal processing is resumed.
  844. Example :
  845. \begin{verbatim}
  846. #IFNDEF VER0_99_5
  847. -Up/usr/lib/fpc/0.99.6/linuxunits
  848. #ENDIF
  849. \end{verbatim}
  850. In the above example, \file{/usr/lib/fpc/0.99.6/linuxunits} will be added to
  851. the path if you're NOT compiling with version 0.99.5 of the compiler.
  852. \subsection{\#ELSE}
  853. Syntax:
  854. \begin{verbatim}
  855. #ELSE
  856. \end{verbatim}
  857. \var{\#ELSE} can be specified after a \var{\#IFDEF} or \var{\#IFNDEF}
  858. directive as an alternative.
  859. Lines following \var{\#ELSE} are skipped read if the preceding \var{\#IFDEF}
  860. \var{\#IFNDEF} was accepted.
  861. They are skipped until the keyword \var{\#ENDIF} is
  862. encountered, after which normal processing is resumed.
  863. Example :
  864. \begin{verbatim}
  865. #IFDEF VER0_99_5
  866. -Up/usr/lib/fpc/0.99.6/linuxunits
  867. #ELSE
  868. -Up/usr/lib/fpc/0.99.5/linuxunits
  869. #ENDIF
  870. \end{verbatim}
  871. In the above example, \file{/usr/lib/fpc/0.99.5/linuxunits} will be added to
  872. the path if you're compiling with version 0.99.5 of the compiler,
  873. otherwise \file{/usr/lib/fpc/0.99.6/linuxunits} will be added to the path.
  874. \subsection{\#ENDIF}
  875. Syntax:
  876. \begin{verbatim}
  877. #ENDIF
  878. \end{verbatim}
  879. \var{\#ENDIF} marks the end of a block that started with \var{\#IF(N)DEF},
  880. possibly with an \var{\#ELSE} between it.
  881. \subsection{\#DEFINE}
  882. Syntax:
  883. \begin{verbatim}
  884. #DEFINE name
  885. \end{verbatim}
  886. \var{\#DEFINE} defines a new keyword. This has the same effect as a
  887. \var{-dname} command-line option.
  888. \subsection{\#UNDEF}
  889. Syntax:
  890. \begin{verbatim}
  891. #UNDEF name
  892. \end{verbatim}
  893. \var{\#UNDEF} un-defines a keyword if it existed.
  894. This has the same effect as a \var{-uname} command-line option.
  895. \subsection{\#WRITE}
  896. Syntax:
  897. \begin{verbatim}
  898. #WRITE Message Text
  899. \end{verbatim}
  900. \var{\#WRITE} writes \var{Message Text} to the screen.
  901. This can be useful to display warnings if certain options are set.
  902. Example:
  903. \begin{verbatim}
  904. #IFDEF DEBUG
  905. #WRITE Setting debugging ON...
  906. -g
  907. #ENDIF
  908. \end{verbatim}
  909. if \var{DEBUG} is defined, this will produce a line
  910. \begin{verbatim}
  911. Setting debugging ON...
  912. \end{verbatim}
  913. and will then switch on debugging information in the compiler.
  914. \subsection{\#INCLUDE}
  915. Syntax:
  916. \begin{verbatim}
  917. #INCLUDE filename
  918. \end{verbatim}
  919. \var{\#INCLUDE} instructs the compiler to read the contents of
  920. \file{filename} before continuing to process the current file.
  921. This can be useful if you want to have a particular configuration file
  922. for a project (or, under \linux, in your home directory), but still want to
  923. have the global options that are set in a global configuration file.
  924. Example:
  925. \begin{verbatim}
  926. #IFDEF LINUX
  927. #INCLUDE /etc/ppc386.cfg
  928. #IFDEF DOS
  929. #INCLUDE c:\pp\bin\ppc386.cfg
  930. #ENDIF
  931. \end{erbatim}
  932. This will include \file{/etc/ppc386.cfg} if you're on a linux machine,
  933. and will include \file{c:\backslash pp\backslash bin\backslash ppc386.cfg}
  934. on a dos machine.
  935. \subsection{\#SECTION}
  936. Syntax:
  937. \begin{verbatim}
  938. #SECTION name
  939. \end{verbatim}
  940. The \var{\#SECTION} directive acts as a \var{\#IFDEF} directive, only
  941. it doesn't require an \var{\#ENDIF} directive. the special name \var{COMMON}
  942. always exists, i.e. lines following \var{\#SECTION COMMON} are always read.
  943. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  944. % Porting.
  945. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  946. \chapter{Porting Turbo Pascal Code}
  947. \fpc was designed to resemble Turbo Pascal as closely as possible. There
  948. are, of course, restrictions. Some of these are due to the fact that \fpc is
  949. a 32-bit compiler. Other restrictions result from the fact that \fpc works
  950. on more than one operating system.
  951. In general we can say that if you keep your program code close to ANSI
  952. Pascal, you will have no problems porting from Turbo Pascal, or even Delphi, to
  953. \fpc. To a large extent, the constructs defined by Turbo Pascal are
  954. supported.
  955. In the following sections we will list the Turbo Pascal constructs which are
  956. not supported in \fpc, and we will list in what ways \fpc extends the Turbo
  957. Pascal language.
  958. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  959. % Things that will not work
  960. \section{Things that will not work}
  961. Here we give a list of things which are defined/allowed in Turbo Pascal, but
  962. which are not supported by \fpc. Where possible, we indicate the reason.
  963. \begin{enumerate}
  964. \item Parameter lists of previously defined functions and procedures must
  965. match exactly. The reason for this is the function overloading mechanism of
  966. \fpc. (however, \seeo{So})
  967. \item \var {(* ... *)} as comment delimiters are not allowed in versions
  968. older than 0.9.1. This can easily be remedied with a grown-up editor.
  969. \item The \var{MEM, MEMW, MEML} and \var{PORT} variables for memory and port
  970. access are not available. This is due to the operating system. Under
  971. \dos, the extender unit (\file {GO32.PPU} provides functions to remedy this.
  972. \item \var{PROTECTED, PUBLIC, TRY, THROW, EXCEPTION} are reserved words.
  973. This means you cannot create procedures or variables with the same name.
  974. While they are not reserved words in Turbo Pascal, they are in Delphi.
  975. \item The reserved words \var{FAR, NEAR} are ignored. This is
  976. because \fpc is a 32 bit compiler, so they're obsolete.
  977. \item \var{INTERRUPT} only will work on a DOS machine.
  978. \item Boolean expressions are only evaluated until their result is completely
  979. determined. The rest of the expression will be ignored.
  980. \item At the moment of writing, the assembler syntax used in \fpc is \var{AT\&T}
  981. assembler syntax. This is mainly because \fpc uses \gnu \var{as}.
  982. \item Turbo Vision is not available.
  983. \item The 'overlay' unit is not available. It also isn't necessary, since
  984. \fpc is a 32 bit compiler, so program size shouldn't be a point.
  985. \item There are more reserved words. (see appendix \ref{ch:reserved} for a
  986. list of all reserved words.)
  987. \item The command-line parameters of the compiler are different.
  988. \item The compiler switches behave different.
  989. \item Units are not binary compatible.
  990. \end{enumerate}
  991. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  992. % Things which are extra
  993. \section{Things which are extra}
  994. Here we give a list of things which are possible in \fpc, but which
  995. didn't exist in Turbo Pascal or Delphi.
  996. \begin{enumerate}
  997. \item There are more reserved words. (see appendix \ref{ch:reserved} for a
  998. list of all reserved words.)
  999. \item Functions can also return complex types, such as records and arrays.
  1000. \item You can handle function results in the function itself, as a variable.
  1001. Example
  1002. \begin{verbatim}
  1003. function a : longint;
  1004. begin
  1005. a:=12;
  1006. while a>4 do
  1007. begin
  1008. {...}
  1009. end;
  1010. end;
  1011. \end{verbatim}
  1012. The example above would work with TP, but the compiler would assume
  1013. that the \var{a>4} is a recursive call. To do a recursive call in
  1014. this you must append \var{()} behind the function name:
  1015. \begin{verbatim}
  1016. function a : longint;
  1017. begin
  1018. a:=12;
  1019. { this is the recursive call }
  1020. if a()>4 then
  1021. begin
  1022. {...}
  1023. end;
  1024. end;
  1025. \end{verbatim}
  1026. \item There is partial support of Delphi constructs. (see the \progref for
  1027. more information on this).
  1028. \item The \var{exit} call accepts a return value for functions.
  1029. \begin{verbatim}
  1030. function a : longint;
  1031. begin
  1032. a:=12;
  1033. if a>4 then
  1034. begin
  1035. exit(a*67); {function result upon exit is a*67 }
  1036. end;
  1037. end;
  1038. \end{verbatim}
  1039. \item \fpc supports function overloading. That is, you can define many
  1040. functions with the same name, but with different arguments. For example:
  1041. \begin{verbatim}
  1042. procedure DoSomething (a : longint);
  1043. begin
  1044. {...}
  1045. end;
  1046. procedure DoSomething (a : real);
  1047. begin
  1048. {...}
  1049. end;
  1050. \end{verbatim}
  1051. You can then call procedure \var{DoSomething} with an argument of type
  1052. \var{Longint} or \var{Real}.\\
  1053. This feature has the consequence that a previously declared function must
  1054. always be defined with the header completely the same:
  1055. \begin{verbatim}
  1056. procedure x (v : longint); forward;
  1057. {...}
  1058. procedure x;{ This will overload the previously declared x}
  1059. begin
  1060. {...}
  1061. end;
  1062. \end{verbatim}
  1063. This construction will generate a compiler error, because the compiler
  1064. didn't find a definition of \var{procedure x (v : longint);}. Instead you
  1065. should define your procedure x as:
  1066. \begin{verbatim}
  1067. procedure x (v : longint);
  1068. { This correctly defines the previously declared x}
  1069. begin
  1070. {...}
  1071. end;
  1072. \end{verbatim}
  1073. \end{enumerate}
  1074. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1075. % Turbo Pascal compatibility mode
  1076. \section{Turbo Pascal compatibility mode}
  1077. When you compile a program with the \var{-So} switch, the compiler will
  1078. attempt to mimic the Turbo Pascal compiler in the following ways:
  1079. \begin{itemize}
  1080. \item Assigning a procedural variable doesn't require a @ operator. One of
  1081. the differences between Turbo Pascal and \fpc is that the latter requires
  1082. you to specify an address operator when assigning a value to a procedural
  1083. variable. In Turbo Pascal compatibility mode, this is not required.
  1084. \item Procedure overloading is disabled.
  1085. \item Forward defined procedures don't need the full parameter list when
  1086. they are defined. Due to the procedure overloading feature of \fpc, you must
  1087. always specify the parameter list of a function when you define it, even
  1088. when it was declared earlier with \var{Forward}. In Turbo Pascal
  1089. compatibility mode, there is no function overloading, hence you can omit the
  1090. parameter list:
  1091. \begin{verbatim}
  1092. Procedure a (L : Longint); Forward;
  1093. ...
  1094. Procedure a ; { No need to repeat the (L : Longint) }
  1095. begin
  1096. ...
  1097. end;
  1098. \end{verbatim}
  1099. \item recursive function calls are handled dfferently. Consider the
  1100. following example :
  1101. \begin{verbatim}
  1102. Function expr : Longint;
  1103. begin
  1104. ...
  1105. Expr:=L:
  1106. Writeln (Expr);
  1107. ...
  1108. end;
  1109. \end{verbatim}
  1110. In Turbo Pascal compatibility mode, the function will be called recursively
  1111. when the \var{writeln} statement is processed. In \fpc, the function result
  1112. will be printed. In order to call the function recusively under \fpc, you
  1113. need to implement it as follows :
  1114. \begin{verbatim}
  1115. Function expr : Longint;
  1116. begin
  1117. ...
  1118. Expr:=L:
  1119. Writeln (Expr());
  1120. ...
  1121. end;
  1122. \end{verbatim}
  1123. \item Any text after the final \var{End.} statement is ignored. Normally,
  1124. this text is processed too.
  1125. \item You cannot assign procedural variables to void pointers.
  1126. \item The @ operator is typed when applied on procedures.
  1127. \item You cannot nest comments.
  1128. \end{itemize}
  1129. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1130. % Utilities.
  1131. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1132. \chapter{Utilities and units that come with Free Pascal}
  1133. \label{ch:Utilities}
  1134. Besides the compiler and the Run-Time Library, \fpc comes with some utility
  1135. programs and units. Here we list these programs and units.
  1136. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1137. % Supplied programs
  1138. \section{Supplied programs}
  1139. \begin{itemize}
  1140. \item \file{dumppu} is a program which shows the contents of a \fpc unit. It
  1141. comes in source form, and must be compiled before you can use it. Once
  1142. compiled, you can just issue the following command
  1143. \begin{verbatim}
  1144. dumppu foo.ppu
  1145. \end{verbatim}
  1146. to display the contents of the \file{foo.ppu} unit.
  1147. \item Also distributed with Free Pascal comes a series of demonstration programs.
  1148. These programs have no other purpose than demonstrating the capabilities of
  1149. \fpc. They are located in the \file{demo} directory of the sources.
  1150. \item All example programs of the documentation are available. Check out the
  1151. directories that end on \file{ex} in the documentation sources. There you
  1152. will find all example sources.
  1153. \item \file{ppumove} is a program to make shared or static libraries from
  1154. units. It should be distributed in binary form along with the compiler.
  1155. \end{itemize}
  1156. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1157. % Supplied units
  1158. \section{Supplied units}
  1159. Here we list the units that come with the \fpc distribution. Since there is
  1160. a difference in the supplied units per operating system, we list them
  1161. separately per system. They are documented in the \unitsref.
  1162. %
  1163. % Under DOS
  1164. %
  1165. \subsection{Under DOS}
  1166. \begin{itemize}
  1167. \item [strings] This unit provides basic
  1168. string handling routines for the \var{pchar} type, comparable to similar
  1169. routines in standard \var{C} libraries.
  1170. \item [objects] This unit provides basic
  1171. routines for handling objects.
  1172. \item [dos] This unit provides basic routines for
  1173. accessing the operating system \dos. It provides almost the same
  1174. functionality as the Turbo Pascal unit.
  1175. \item [printer] This unit provides all you
  1176. need for rudimentary access to the printer.
  1177. \item [getopts] This unit gives you the
  1178. \gnu \var{getopts} command-line arguments handling mechanism.
  1179. It also supports long options.
  1180. \item [crt] This unit provides basic screen
  1181. handling routines. It provides the same functionality as the Turbo Pascal \var{CRT}
  1182. unit.
  1183. \item [graph] This unit provides basic graphics
  1184. handling, with routines to draw lines on the screen, display texts etc. It
  1185. provides the same functions as the Turbo Pascal unit.
  1186. \item [go32] This unit provides access to possibilities of the \var{GO32}
  1187. \dos extender.
  1188. \item [emu387] This unit provides support for the coprocessor emulator.
  1189. \item [mmx] This unit provides support for \var{mmx} extensions in your
  1190. code.
  1191. \end{itemize}
  1192. %
  1193. % Under Linux
  1194. %
  1195. \subsection{Under Linux}
  1196. \begin{itemize}
  1197. \item [strings] This unit provides basic
  1198. string handling routines for the \var{PChar} type, comparable to similar
  1199. routines in standard \var{C} libraries.
  1200. \item [objects] This unit provides basic
  1201. routines for handling objects.
  1202. \item [crt] This unit provides basic screen
  1203. handling routines. It provides the same functionality Turbo Pascal \var{CRT}
  1204. unit. It works on any terminal which supports the \var{vt100} escape
  1205. sequences.
  1206. \item [dos] This unit provides an emulation of the
  1207. same unit under \dos. It is intended primarily for easy porting of Pascal
  1208. programs from \dos to \linux. For good performance, however, it is
  1209. recommended to use the \var{linux} unit.
  1210. \item [linux] This unit provides access to the
  1211. \linux operating system. It provides most file and I/O handling routines
  1212. that you may need. It implements most of the standard \var{C} library constructs
  1213. that you will find on a Unix system. If you do a lot of disk/file
  1214. operations, the use of this unit is recommended over the one you use under
  1215. Dos.
  1216. \item [printer] This unit provides an
  1217. interface to the standard Unix printing mechanism.
  1218. \item [getopts] This unit gives you the
  1219. \gnu \var{getopts} command-line arguments handling mechanism.
  1220. It also supports long options.
  1221. \item [mmx] This unit provides support for \var{mmx} extensions in your
  1222. code.
  1223. \item [sockets] This unit gives you access to sockets and TCP/IP
  1224. programming.
  1225. \end{itemize}
  1226. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1227. % Debugging
  1228. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1229. \chapter{Debugging your Programs}
  1230. \fpc supports debug information for the \gnu debugger \var{gdb}.
  1231. This chapter describes shortly how to use this feature. It doesn't attempt
  1232. to describe completely the \gnu debugger, however.
  1233. For more information on the workings of the \gnu debugger, see the \var{gdb}
  1234. users' guide.
  1235. \fpc also suports \var{gprof}, the \gnu profiler, see section \ref{se:gprof}
  1236. for more information on profiling.
  1237. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1238. % Compiling your program with debugger support
  1239. \section{Compiling your program with debugger support}
  1240. First of all, you must be sure that the compiler is compiled with debugging
  1241. support. Unfortunately, there is no way to check this at run time, except by
  1242. trying to compile a program with debugging support.
  1243. To compile a program with debugging support, just specify the \var{-g}
  1244. option on the command-line, as follows:
  1245. \begin{verbatim}
  1246. ppc386 -g hello.pp
  1247. \end{verbatim}
  1248. This will generate debugging information in the executable from your
  1249. program. You will notice that the size of the executable increases
  1250. substantially because of this\footnote{A good reason not to include debug
  1251. information in an executable you plan to distribute.}.
  1252. Note that the above will only generate debug information {\var for the code
  1253. that has been generated} when compiling \file{hello.pp}. This means that if
  1254. you used some units (the system unit, for instance) which were not compiled
  1255. with debugging support, no debugging support will be available for the code
  1256. in these units.
  1257. There are 2 solutions for this problem.
  1258. \begin{enumerate}
  1259. \item Recompile all units manually with the \var{-g} option.
  1260. \item Specify the 'build' option (\var{-B}) when compiling with debugging
  1261. support. This will recompile all units, and insert debugging information in
  1262. each of the units.
  1263. \end{enumerate}
  1264. The second option may have undesirable side effects. It may be that some
  1265. units aren't found, or compile incorrectly due to missing conditionals,
  1266. etc..
  1267. If all went well, the executable now contains the necessary information with
  1268. which you can debug it using \gnu \var{gdb}.
  1269. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1270. % Using gdb
  1271. \section{Using \var{gdb} to debug your program}
  1272. To use gdb to debug your program, you can start the debugger, and give it as
  1273. an option the {\em full} name of your program:
  1274. \begin{verbatim}
  1275. gdb hello
  1276. \end{verbatim}
  1277. Or, under \dos :
  1278. \begin{verbatim}
  1279. gdb hello.exe
  1280. \end{verbatim}
  1281. This starts the debugger, and the debugger immediately loads your program
  1282. into memory, but it does not run the program yet. Instead, you are presented
  1283. with the following (more or less) message, followed by the \var{gdb} prompt
  1284. \var{'(gdb)'}:
  1285. \begin{verbatim}
  1286. GDB is free software and you are welcome to distribute copies of it
  1287. under certain conditions; type "show copying" to see the conditions.
  1288. There is absolutely no warranty for GDB; type "show warranty" for details.
  1289. GDB 4.15.1 (i486-slackware-linux),
  1290. Copyright 1995 Free Software Foundation, Inc...
  1291. (gdb)
  1292. \end{verbatim}
  1293. To start the program you can use the \var{run} command. You can optionally
  1294. specify command-line parameters, which will then be fed to your program, for
  1295. example:
  1296. \begin{verbatim}
  1297. (gdb) run -option -anotheroption needed_argument
  1298. \end{verbatim}
  1299. If your program runs without problems, \var{gdb} will inform you of this,
  1300. and return the exit code of your program. If the exit code was zero, then
  1301. the message \var{'Program exited normally'}.
  1302. If something went wrong (a segmentation fault or so), \var{gdb} will stop
  1303. the execution of your program, and inform you of this with an appropriate
  1304. message. You can then use the other \var{gdb} commands to see what happened.
  1305. Alternatively, you can instruct \var{gdb} to stop at a certain point in your
  1306. program, with the \var{break} command.
  1307. Here is a short list of \var{gdb} commands, which you are likely to need when
  1308. debugging your program:
  1309. \begin{description}
  1310. \item [quit\ ] Exits the debugger.
  1311. \item [kill\ ] Stops a running program.
  1312. \item [help\ ] Gives help on all \var{gdb} commands.
  1313. \item [file\ ] Loads a new program into the debugger.
  1314. \item [directory\ ] Add a new directory to the search path for source
  1315. files.\\
  1316. {\em Remark:} My copy of gdb needs '.' to be added explicitly to the search
  1317. path, otherwise it doesn't find the sources.
  1318. \item [list\ ] Lists the program sources per 10 lines. As an option you can
  1319. specify a line number or function name.
  1320. \item [break\ ] Sets a breakpoint at a specified line or function
  1321. \item [awatch\ ] Sets a watch-point for an expression. A watch-point stops
  1322. execution of your program whenever the value of an expression is either
  1323. read or written.
  1324. \end{description}
  1325. for more information, see the \var{gdb} users' guide, or use the \var{'help'}
  1326. function in \var{gdb}.
  1327. The appendix {\ref{ch:GdbIniFile}} contains a sample init file for
  1328. \var{gdb}, which produces good results when debugging \fpc programs.
  1329. \section{Caveats when debugging with \var{gdb}}
  1330. There are some peculiarities of \fpc which you should be aware of when using
  1331. \var{gdb}. We list the main ones here:
  1332. \begin{enumerate}
  1333. \item \fpc generates information for GDB in uppercare letters. This is a
  1334. consequence of the fact that pascal is a case insensitive language. So, when
  1335. referring to a variable or function, you need to make it's name all
  1336. uppercase.
  1337. As an example, of you want to watch the value of a loop variable
  1338. \var{count}, you should type
  1339. \begin{verbatim}
  1340. watch COUNT
  1341. \end{verbatim}
  1342. Or if you want stop when a certain function (e.g \var{MyFunction}) is called,
  1343. type
  1344. \begin{verbatim}
  1345. break MYFUNCTION
  1346. \end{verbatim}
  1347. \item Line numbers may be off by a little. This is a bug in \fpc and will be
  1348. fixed as soon as possible.
  1349. \item \var{gdb} does not know sets.
  1350. \item \var{gdb} doesn't know strings. Strings are represented in \var{gdb}
  1351. as records with a length field and an array of char contaning the string.
  1352. You can also use the following user function to print strings:
  1353. \begin{verbatim}
  1354. define pst
  1355. set $pos=&$arg0
  1356. set $strlen = {byte}$pos
  1357. print {char}&$arg0.st@($strlen+1)
  1358. end
  1359. document pst
  1360. Print out a Pascal string
  1361. end
  1362. \end{verbatim}
  1363. If you insert it in your \file{gdb.ini} file, you can look at a string with this
  1364. function. There is a sample \file{gdb.ini} in appendix \ref{ch:GdbIniFile}.
  1365. \item Objects are difficult to handle, mainly because \var{gdb} is oriented
  1366. towards C and C++. The workaround implemented in \fpc is that object methods
  1367. are represented as functions, with an extra parameter \var{this} (all
  1368. lowercase !) The name of this function is a concatenation of the object type
  1369. and the function name, separated by two underscore characters.
  1370. For example, the method \var{TPoint.Draw} would be converted to
  1371. \var{TPOINT\_\_DRAW}, and could be stopped at with
  1372. \begin{verbatim}
  1373. break TPOINT__DRAW
  1374. \end{verbatim}
  1375. \item Global overloaded functions confuse \var{gdb} because they have the same
  1376. name. Thus you cannot set a breakpoint at an overloaded function, unless you
  1377. know it's line number, in which case you can set a breakpoint at the
  1378. starting linenumber of the function.
  1379. \end{enumerate}
  1380. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1381. % Using gprof
  1382. \section{Support for \var{gprof}, the \gnu profiler}
  1383. \label{se:gprof}
  1384. You can compile your programs with profiling support. for this, you just
  1385. have to use the compiler switch \var{-pg}. The compiler wil insert the
  1386. necessary stuff for profiling.
  1387. When you have done this, you can run your program uder the gnu profiler,
  1388. \var{gprof}, as follows :
  1389. \begin{verbatim}
  1390. gprog yourexe
  1391. \end{verbatim}
  1392. Where \file{yourexe} is the name of your executable.
  1393. You may want to capture the outpus of the profiler in a file, since it can
  1394. be quite a lot, as follows:
  1395. \begin{verbatim}
  1396. gprog yourexe >gprof.out
  1397. \end{verbatim}
  1398. For more information on the \gnu profiler \var{gprof}, see its manual.
  1399. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1400. % CGI.
  1401. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1402. \chapter{CGI programming in Free Pascal}
  1403. \label{ch:CGIProgramming}
  1404. In these days of heavy WWW traffic on the Internet, CGI scripts have become
  1405. an important topic in computer programming. While CGI programming can be
  1406. done with almost any tool you wish, most languages aren't designed for it.
  1407. Perl may be a notable exception, but perl is an interpreted language, the
  1408. executable is quite big, and hence puts a big load on the server machine.
  1409. Because of its simple, almost intuitive, string handling and its easy syntax,
  1410. Pascal is very well suited for CGI programming. Pascal allows you to quickly
  1411. produce some results, while giving you all the tools you need for more
  1412. complex programming. The basic RTL routines in principle are enough to get
  1413. the job done, but you can create, with relatively little effort, some units
  1414. which can be used as a base for more complex CGI programming.
  1415. That's why, in this chapter, we will discuss the basics of CGI in \fpc.
  1416. In the subsequent, we will assume that the server for which the programs are
  1417. created, are based upon the NCSA \var{httpd} WWW server, as the examples
  1418. will be based upon the NCSA method of CGI programming\footnote{... and it's
  1419. the only WWW-server I have to my disposition at the moment.}.
  1420. The two example programs in this chapter have been tested on the command line
  1421. and worked, under the condition that no spaces were present in the name and
  1422. value pairs provided to them.
  1423. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1424. % Getting your data
  1425. \section{Getting your data}
  1426. Your CGI program must react on data the user has filled in on the form which
  1427. your web-server gave him. The Web server takes the response on the form, and
  1428. feeds it to the CGI script.
  1429. There are essentially two ways of feeding the data to the CGI script. We will
  1430. discuss both.
  1431. %
  1432. %
  1433. % Data coming through standard input.
  1434. \subsection{Data coming through standard input.}
  1435. The first method of getting your data is through standard input. This method
  1436. is invoked when the form uses a form submission method of \var{POST}.
  1437. The web browser sets three environment variables \var{REQUEST\_METHOD},
  1438. \var{CONTENT\_TYPE} and \var{CONTENT\_LENGTH}. It feeds then the results of
  1439. the different fields through standard input to the CGI script.
  1440. All the Pascal program has to do is :
  1441. \begin{itemize}
  1442. \item Check the value of the \var{REQUEST\_METHOD} environment variable. The
  1443. \var{getenv} function will retrieve this value this for you.
  1444. \item Check the value of the \var{CONTENT\_TYPE} environment variable.
  1445. \item Read \var{CONTENT\_LENGTH} characters from standard input. \var{read
  1446. (c)} with \var{c} of type \var{char} will take care of that.
  1447. \end{itemize}
  1448. if you know that the request method will always be \var{POST}, and the
  1449. \var{CONTENT\_TYPE} will be correct, then you can skip the first two steps.
  1450. The third step can be done easier: read characters until you reach the
  1451. end-of-file marker of standard input.
  1452. The following example shows how this can be achieved:
  1453. \begin{verbatim}
  1454. program cgi_post;
  1455. uses dos;
  1456. const max_data = 1000;
  1457. type datarec = record
  1458. name,value : string;
  1459. end;
  1460. var data : array[1..max_data] of datarec;
  1461. i,nrdata : longint;
  1462. c : char;
  1463. literal,aname : boolean;
  1464. begin
  1465. writeln ('Content-type: text/html');
  1466. writeln;
  1467. if getenv('REQUEST_METHOD')<>'POST' then
  1468. begin
  1469. writeln ('This script should be referenced with a METHOD of POST');
  1470. write ('If you don''t understand this, see this ');
  1471. write ('< A HREF="http://www.ncsa.uiuc.edu/SDG/Softare/Mosaic');
  1472. writeln ('/Docs/fill-out-forms/overview.html">forms overview</A>.');
  1473. halt(1);
  1474. end;
  1475. if getenv('CONTENT_TYPE')<>'application/x-www-form-urlencoded' then
  1476. begin
  1477. writeln ('This script can only be used to decode form results');
  1478. halt(1)
  1479. end;
  1480. nrdata:=1;
  1481. aname:=true;
  1482. while not eof(input) do
  1483. begin
  1484. literal:=false;
  1485. read(c);
  1486. if c='\' then
  1487. begin
  1488. literal:=true;
  1489. read(c);
  1490. end;
  1491. if literal or ((c<>'=') and (c<>'&')) then
  1492. with data[nrdata] do
  1493. if aname then name:=name+c else value:=value+c
  1494. else
  1495. begin
  1496. if c='&' then
  1497. begin
  1498. inc (nrdata);
  1499. aname:=true;
  1500. end
  1501. else
  1502. aname:=false;
  1503. end
  1504. end;
  1505. writeln ('<H1>Form Results :</H1>');
  1506. writeln ('You submitted the following name/value pairs :');
  1507. writeln ('<UL>');
  1508. for i:=1 to nrdata do writeln ('<LI> ',data[i].name,' = ',data[i].value);
  1509. writeln ('</UL>');
  1510. end.
  1511. \end{verbatim}
  1512. While this program isn't shorter than the C program provided as an example
  1513. at NCSA, it doesn't need any other units. everythig is done using standard
  1514. Pascal procedures\footnote{actually, this program will give faulty results,
  1515. since spaces in the input are converted to plus signs by the web browser.
  1516. The program doesn't check for this, but that is easy to change.
  1517. The main concern here is to give the working principle.}.
  1518. Note that this program has a limitation: the length of names and values is
  1519. limited to 255 characters. This is due to the fact that strings in Pascal
  1520. have a maximal length of 255. It is of course easy to redefine the
  1521. \var{datarec} record in such a way that longer values are allowed.
  1522. In case you have to read the contents of a \var{TEXTAREA} form element,
  1523. this may be needed.
  1524. % Data passed through an environment variable
  1525. \subsection{Data passed through an environment variable}
  1526. If your form uses the \var{GET} method of passing it's data, the CGI script
  1527. needs to read the \var{QUERY\_STRING} environment variable to get it's data.
  1528. Since this variable can, and probably will, be more than 255 characters long,
  1529. you will not be able to use normal string methods, present in pascal. \fpc
  1530. implements the \var{pchar} type, which is a pointer to a null-terminated
  1531. array of characters.
  1532. And, fortunately, \fpc has a
  1533. \seestrings\ unit, which eases the use of the
  1534. \var{pchar} type.
  1535. The following example illustrates what to do in case of a method of \var{GET}
  1536. \begin{verbatim}
  1537. program cgi_get;
  1538. uses strings,linux;
  1539. const max_data = 1000;
  1540. type datarec = record
  1541. name,value : string;
  1542. end;
  1543. var data : array[1..max_data] of datarec;
  1544. i,nrdata : longint;
  1545. p : PChar;
  1546. literal,aname : boolean;
  1547. begin
  1548. Writeln ('Content-type: text/html');
  1549. Writeln;
  1550. if StrComp(GetEnv('REQUEST_METHOD'),'POST')<>0 then
  1551. begin
  1552. Writeln ('This script should be referenced with a METHOD of GET');
  1553. write ('If you don''t understand this, see this ');
  1554. write ('< A HREF="http://www.ncsa.uiuc.edu/SDG/Softare/Mosaic');
  1555. Writeln ('/Docs/fill-out-forms/overview.html">forms overview</A>.');
  1556. halt(1);
  1557. end;
  1558. p:=GetEnv('QUERY_STRING');
  1559. nrdata:=1;
  1560. aname:=true;
  1561. while p^<>#0 do
  1562. begin
  1563. literal:=false;
  1564. if p^='\' then
  1565. begin
  1566. literal:=true;
  1567. inc(longint(p));
  1568. end;
  1569. if ((p^<>'=') and (p^<>'&')) or literal then
  1570. with data[nrdata] do
  1571. if aname then name:=name+p^ else value:=value+p^
  1572. else
  1573. begin
  1574. if p^='&' then
  1575. begin
  1576. inc (nrdata);
  1577. aname:=true;
  1578. end
  1579. else
  1580. aname:=false;
  1581. end;
  1582. inc(longint(p));
  1583. end;
  1584. Writeln ('<H1>Form Results :</H1>');
  1585. Writeln ('You submitted the following name/value pairs :');
  1586. Writeln ('<UL>');
  1587. for i:=1 to nrdata do writeln ('<LI> ',data[i].name,' = ',data[i].value);
  1588. Writeln ('</UL>');
  1589. end.
  1590. \end{verbatim}
  1591. Although it may not be written in the most elegant way, this program does
  1592. the same thing as the previous one. It also suffers from the same drawback,
  1593. namely the limited length of the \var{value} field of the \var{datarec}.
  1594. This drawback can be remedied by redefining \var{datarec} as follows:
  1595. \begin{verbatim}
  1596. type datarec = record;
  1597. name,value : pchar;
  1598. end;
  1599. \end{verbatim}
  1600. and assigning at run time enough space to keep the contents of the value
  1601. field. This can be done with a
  1602. \begin{verbatim}
  1603. getmem (data[nrdata].value,needed_number_of_bytes);
  1604. \end{verbatim}
  1605. call. After that you can do a
  1606. \begin{verbatim}
  1607. strlcopy (data[nrdata].value,p,needed_number_of_bytes);
  1608. \end{verbatim}
  1609. to copy the data into place.
  1610. You may have noticed the following unorthodox call :
  1611. \begin{verbatim}
  1612. inc(longint(p));
  1613. \end{verbatim}
  1614. \fpc doesn't give you pointer arithmetic as in C. However, \var{longints} and
  1615. \var{pointers} have the same length (namely 4 bytes). Doing a type-cast to a
  1616. \var{longint} allows you to do arithmetic on the \var{pointer}.
  1617. Note however, that this is a non-portable call. This may work on the I386
  1618. processor, but not on a ALPHA processor (where a pointer is 8 bytes long).
  1619. This will be remedied in future releases of \fpc.
  1620. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1621. % Producing output
  1622. \section{Producing output}
  1623. The previous section concentrated mostly on getting input from the web
  1624. server. To send the reply to the server, you don't need to do anything
  1625. special.You just print your data on standard output, and the Web-server will
  1626. intercept this, and send your output to the WWW-client waiting for it.
  1627. You can print anything you want, the only thing you must take care of is
  1628. that you supply a \var{Contents-type} line, followed by an empty line, as
  1629. follows:
  1630. \begin{verbatim}
  1631. Writeln ('Content-type: text/html');
  1632. Writeln;
  1633. { ...start output of the form... }
  1634. \end{verbatim}
  1635. And that's all there is to it !
  1636. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1637. % I'm under Windows, what now ?
  1638. \section{I'm under Windows, what now ?}
  1639. Under Windows the system of writing CGI scripts is totally different. If you
  1640. use \fpc under Windows then you also should be able to do CGI programming,
  1641. but the above instructions will not work.
  1642. If some kind soul is willing to write a section on CGI programming under
  1643. Windows, I'd be willing to include it here.
  1644. \appendix
  1645. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1646. % APPENDIX A.
  1647. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1648. \chapter{Alphabetical listing of command-line options}
  1649. The following is alphabetical listing of all command-line options, as
  1650. generated by the compiler:
  1651. \begin{verbatim}
  1652. ppc386 [options] <inputfile> [options]
  1653. + switch option on, - off
  1654. -a the compiler doesn't delete the generated assembler file
  1655. -B+ build
  1656. -C code generation options
  1657. -Ca not implemented
  1658. -Ce not implemented
  1659. -CD Dynamic linking
  1660. -Ch<n> <n> bytes heap (between 1023 and 67107840)
  1661. -Ci IO-checking
  1662. -Cn omit linking stage
  1663. -Co check overflow of integer operations
  1664. -Cr range checking
  1665. -Ct stack checking
  1666. -CS static linking
  1667. -d<x> defines the symbol <x>
  1668. -e<x> set path to executables
  1669. -E same as -Cn
  1670. -g generate debugger information
  1671. -gp generate also profile code for gprof
  1672. -F set file names and paths
  1673. -Fe<x> redirect error output to <x>
  1674. -Fg<x> <x> search path for the GNU C lib
  1675. -Fr<x> <x> search path for the error message file
  1676. -Fi<x> adds <x> to include path
  1677. -Fl<x> adds <x> to library path
  1678. -Fu<x> adds <x> to unit path
  1679. -k<x> Pass <x> to the linker
  1680. -L set language
  1681. -LD german
  1682. -LE english
  1683. -l write logo
  1684. -i information
  1685. -n don't read the default config file
  1686. -o<x> change the name of the executable produced to <x>
  1687. -pg generate profile code for gprof
  1688. -P use pipes instead of creating temporary assembler files
  1689. -S syntax options
  1690. -S2 switch some Delphi 2 extension on
  1691. -Sc supports operators like C (*=,+=,/= and -=)
  1692. -Se compiler stops after the first error
  1693. -Sg allows LABEL and GOTO
  1694. -Si support C++ stlyed INLINE
  1695. -Sm support macros like C (global)
  1696. -So tries to be TP/BP 7.0 compatible
  1697. -Ss constructor name must be init (destructor must be done)
  1698. -St allows static keyword in objects
  1699. -s don't call assembler and linker (only with -a)
  1700. -T<x> Target operating system
  1701. -TGO32V1 DOS extender by DJ Delorie
  1702. -TOS2 OS/2 2.x
  1703. -TLINUX Linux
  1704. -TWin32 Windows 32 Bit
  1705. -TGO32V2 version 2 of DJ Delorie DOS extender
  1706. -u<x> undefines the symbol <x>
  1707. -U unit options
  1708. -Uls make static library from unit
  1709. -Uld make dynamic library from unit
  1710. -Un don't check the unit name
  1711. -Up<x> same as -Fu<x>
  1712. -Us compile a system unit
  1713. -v<x> Be verbose. <x> is a combination of the following letters :
  1714. e : Show errors (default) d : Show debug info
  1715. w : Show warnings u : Show used files
  1716. n : Show notes t : Show tried files
  1717. h : Show hints m : Show defined macros
  1718. i : Show general info p : Show compiled procedures
  1719. l : Show linenumbers c : Show conditionals
  1720. a : Show everything 0 : Show nothing (except errors)
  1721. -X executable options
  1722. -Xc link with the c library
  1723. -Xs strip all symbols from executable
  1724. Processor specific options:
  1725. -A output format
  1726. -Aatt AT&T assembler
  1727. -Ao coff file using GNU AS
  1728. -Aobj OMF file using NASM
  1729. -Anasm coff file using NASM
  1730. -Amasm assembler for the Microsoft/Borland/Watcom assembler
  1731. -R assembler reading style
  1732. -Ratt read AT&T style assembler
  1733. -Rintel read Intel style assembler
  1734. -Rdirect copy assembler text directly to assembler file
  1735. -O optimizations
  1736. -Oa simple optimizations
  1737. -Og optimize for size
  1738. -OG optimize for time
  1739. -Ox optimize maximum
  1740. -Oz uncertain optimizes (see docs)
  1741. -O2 optimize for Pentium II (tm)
  1742. -O3 optimize for i386
  1743. -O4 optimize for i486
  1744. -O5 optimize for Pentium (tm)
  1745. -O6 optimizations for PentiumPro (tm)
  1746. -? shows this help
  1747. -h shows this help without waiting
  1748. \end{verbatim}
  1749. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1750. % APPENDIX B.
  1751. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1752. \chapter{Alphabetical list of reserved words}
  1753. \label{ch:reserved}
  1754. \latex{\begin{multicols}{3}}% \texttt
  1755. \begin{verbatim}
  1756. absolute
  1757. abstract
  1758. and
  1759. array
  1760. as
  1761. asm
  1762. assembler
  1763. begin
  1764. break
  1765. case
  1766. cdecl
  1767. class
  1768. const
  1769. constructor
  1770. continue
  1771. destructor
  1772. dispose
  1773. div
  1774. do
  1775. downto
  1776. else
  1777. end
  1778. except
  1779. exit
  1780. export
  1781. exports
  1782. external
  1783. fail
  1784. false
  1785. far
  1786. file
  1787. finally
  1788. for
  1789. forward
  1790. function
  1791. goto
  1792. if
  1793. implementation
  1794. in
  1795. index
  1796. inherited
  1797. initialization
  1798. inline
  1799. interface
  1800. interrupt
  1801. is
  1802. label
  1803. library
  1804. mod
  1805. name
  1806. near
  1807. new
  1808. nil
  1809. not
  1810. object
  1811. of
  1812. on
  1813. operator
  1814. or
  1815. otherwise
  1816. packed
  1817. private
  1818. procedure
  1819. program
  1820. property
  1821. protected
  1822. public
  1823. raise
  1824. record
  1825. repeat
  1826. self
  1827. set
  1828. shl
  1829. shr
  1830. stdcall
  1831. string
  1832. then
  1833. to
  1834. true
  1835. try
  1836. type
  1837. unit
  1838. until
  1839. uses
  1840. var
  1841. virtual
  1842. while
  1843. with
  1844. xor
  1845. \end{verbatim}
  1846. \latex{\end{multicols}}
  1847. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1848. % APPENDIX C.
  1849. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1850. \chapter{Compiler error messages}
  1851. \label{ch:ErrorMessages}
  1852. This appendix is meant to list all the compiler errors. the list of compiler
  1853. errors is fairly complete, the assembler errors are less complete.
  1854. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1855. % Compiler errors.
  1856. \section{Compiler errors}
  1857. The following is a list of general compiler errors.
  1858. \begin{description}
  1859. \item [unexpected end of file]
  1860. this typically happens in on of the following cases :
  1861. \begin{itemize}
  1862. \item The source file ends befor then final \var{end.} statement. This
  1863. happens mostly when the \var{begin} and \var{end} statements aren't
  1864. balanced;
  1865. \item An include file ends in the middle of a statement.
  1866. \item A comment wasn't closed.
  1867. \end{itemize}
  1868. \item [duplicate identifier:]
  1869. The identifier was already declared in the current scope.
  1870. \item [syntax error:]
  1871. An error against the Turbo Pascal language was encountered. This happens
  1872. typically when an illegal character is found in the sources file.
  1873. \item [Parser - syntax error]
  1874. An error against the Turbo Pascal language was encountered. This happens
  1875. typically when an illegal character is found in the sources file.
  1876. \item [out of memory]
  1877. The compiler doesn't have enough memory to compile your program. There are
  1878. several remedies for this:
  1879. \begin{itemize}
  1880. \item If you're using the build option of the compiler, try compiling the
  1881. different units manually.
  1882. \item If you're compiling a huge program, split it up in units, and compile
  1883. these separately.
  1884. \item If the previous two don't work, recompile the compiler with a bigger
  1885. heap (you can use the \var{-Ch} option for this, \seeo{Ch})
  1886. \end{itemize}
  1887. \item [unknown identifier]
  1888. The identifier encountered hasn't been declared, or is used outside the
  1889. scope where it's defined.
  1890. \item [illegal character]
  1891. An illegal character was encountered in the input file.
  1892. \item [source too long]
  1893. The compiler cannot cope with source files longer than (???)
  1894. \item [procedure type INLINE not supported]
  1895. You tried to compile a program with C++ style inlining, and forgot to
  1896. specify the \var{-Si} option (\seeo{Si}). The compiler doesn't support C++
  1897. styled inlining by default.
  1898. \item [procedure type NEAR ignored]
  1899. This is a warning. \var{NEAR} is a construct for 8 or 16 bit programs. Since
  1900. the compile generates 32 bit programs, it ignores this directive.
  1901. \item [procedure type FAR ignored]
  1902. This is a warning. \var{FAR} is a construct for 8 or 16 bit programs. Since
  1903. the compile generates 32 bit programs, it ignores this directive.
  1904. \item [INTERRUPT ignored]
  1905. Interrupt procedures aren't possible on operating systems, other than DOS,
  1906. it isn't allowed to take over an interrupt at the user level. (versions
  1907. older than 0.9.2 didn't have \var{INTERRUPT} support.
  1908. \item [private methods shouldn't be VIRTUAL]
  1909. You declared a method in the private part of a object (class) as
  1910. \var{virtual}. This is not allowed. Private methods cannot be overridden
  1911. anyway.
  1912. \item [constructor can't be private or protected]
  1913. Constructors must be in the 'public' part of an object (class) declaration.
  1914. \item [destructor can't be private or protected]
  1915. Destructors must be in the 'public' part of an object (class) declaration.
  1916. \item [identifier not found]
  1917. \item [local class definitions are not allowed]
  1918. Classes must be defined globally.
  1919. \item [anonym class definitions are not allowed]
  1920. \item [type identifier expected]
  1921. The identifier is not a type, or you forgot to supply a type identifier.
  1922. \item [identifier already as type identifier declared]
  1923. You are trying to redefine a type.
  1924. \item [type identifier not defined]
  1925. The compiler encountered an unknown type.
  1926. \item [type mismatch]
  1927. This can happen in many cases:
  1928. \begin{itemize}
  1929. \item The variable you're assigning to is of a different type than the
  1930. expression in the assignment.
  1931. \item You are calling a function or procedure with parameters that are
  1932. incompatible with the parameters in the function or procedure definition.
  1933. \end{itemize}
  1934. \item [statement expected]
  1935. \item [illegal integer constant]
  1936. You made an exression which isn't an integer, and the compiler expects the
  1937. result to be an integer.
  1938. \item [illegal expression]
  1939. \item [expression too complicated - FPU stack overflow]
  1940. Your expression is too long for the compiler. You should try dividing the
  1941. construct over multiple assignments.
  1942. \item [CONTINUE not allowed]
  1943. You're trying to use \var{continue} outside a loop construction.
  1944. \item [BREAK not allowed]
  1945. You're trying to use \var{break} outside a loop construction.
  1946. \item [illegal qualifier]
  1947. One of the following is appending :
  1948. \begin{itemize}
  1949. \item You're trying to access a field of a variable that is not a record.
  1950. \item You're indexing a variable that is not an array.
  1951. \item You're dereferencing a variable that is not a pointer.
  1952. \end{itemize}
  1953. \item [illegal counter variable]
  1954. The type of a \var{for} loop must be ordinal.
  1955. \item [ordinal value expected]
  1956. The expression must be of ordinal type (i.e. maximum a Longint)
  1957. \item [high range limit < low range limit]
  1958. You are declaring a subrange, and the lower limit is higher than the high
  1959. limit of the range.
  1960. \item [illegal unit name]
  1961. The name of the unit doesn't match the file name.
  1962. \item [unknown format of unit file]
  1963. The unit the compiler is trying to read is corrupted, or generated with a
  1964. newer version of the compiler.
  1965. \item [Reading PPU-File]
  1966. The unit the compiler is trying to read is corrupted, or generated with a
  1967. newer version of the compiler.
  1968. \item [Invalid PPU-File entry]
  1969. The unit the compiler is trying to read is corrupted, or generated with a
  1970. newer version of the compiler.
  1971. \item [circular unit use]
  1972. Two units are using each other in the interface part. This is only allowed
  1973. in the implementation part.
  1974. \item [too many units]
  1975. \fpc has a limit of 1024 units in a program. You can change this behavior
  1976. by changing the \var{maxunits} constant in the \file{files.pas} file of the
  1977. compiler, and recompiling the compiler.
  1978. \item [illegal char constant]
  1979. The compiler expects a character constant, but finds something else.
  1980. \item [overloaded identifier isn't a function identifier]
  1981. The compiler encountered a symbol with the same name a s an overloaded
  1982. function, but it isn't a function it can overload.
  1983. \item [overloaded functions have the same parameter list]
  1984. You're declaring overloaded functions, but with the same parameter list.
  1985. Overloaded function must have at least 1 different parameter in their
  1986. declaration.
  1987. \item [illegal parameter list]
  1988. You are calling a function with parameters that are of a different type than
  1989. the declared parameters of the function.
  1990. \item [can't determine which overloaded function to call]
  1991. You're calling overloaded functions with a parameter that doesn't correspond
  1992. to any of the declared function parameter lists. e.g. when you have declared
  1993. a function with parameters \var{word} and \var{longint}, and then you call
  1994. it with a parameter which is of type \var{integer}.
  1995. \item [forward declaration not solved:]
  1996. This can happen in two cases:
  1997. \begin{itemize}
  1998. \item This happens when you declare a function (in the \var{interface} part, or
  1999. with a \var{forward} directive, but do not implement it.
  2000. \item You reference a type which isn't declared in the current \var{type}
  2001. block.
  2002. \end{itemize}
  2003. \item [input file not found]
  2004. \fpc cannot find the program or unit source file, or the included file isn't
  2005. found.
  2006. \item [function header doesn't match the forward declaration]
  2007. You declared the function in the \var{interface} part, or with the
  2008. \var{forward} directive, but define it with a different parameter list.
  2009. \item [unknown field identifier]
  2010. The field doesn't exist in the record definition.
  2011. \item [parameter list size exceeds 65535 bytes]
  2012. The I386 processor limits the parameter list to 65535 bytes (the \var{RET}
  2013. instruction causes this)
  2014. \item [function nesting > 31]
  2015. You can nest function definitions only 31 times.
  2016. \item [illegal compiler switch]
  2017. You included a compiler switch (i.e. \var{\{\$... \}}) which the compiler
  2018. doesn't know.
  2019. \item [can't open include file]
  2020. You want to include (i.e \var{\{\$i file\}}) which the compiler doesn't
  2021. find. Check if the filename is correct.
  2022. \item [record or class type expected]
  2023. The variable or expression isn't of the type \var{record} or \var{class}.
  2024. \item [only values can be jumped over in enumeration types]
  2025. \fpc allows enumeration constructions as in C. Given the following
  2026. declaration two declarations:
  2027. \begin{verbatim}
  2028. type a = (A_A,A_B,A_E=:6,A_UAS:=200);
  2029. type a = (A_A,A_B,A_E=:6,A_UAS:=4);
  2030. \end{verbatim}
  2031. The second declaration would produce an error. \var{A\_UAS} needs to have a
  2032. value higher than \var{A\_E}, i.e. at least 7.
  2033. \item [pointer type expected]
  2034. The variable or expression isn't of the type \var{pointer}.
  2035. \item [unit is compiled for another operating system]
  2036. The unit was compiled with a different target than the target for which
  2037. you're compiling now. (see the option \var{-T} \seeo{T}).
  2038. \item [typed constants of classes are not allowed]
  2039. You cannot declare a constant of type class or object.
  2040. \item [duplicate case label]
  2041. You are specifying the same label 2 times in a \var{case} statement.
  2042. \item [range check error while evaluating constants]
  2043. The constants are out of their allowed range.
  2044. \item [illegal type conversion]
  2045. When doing a type-cast, you must take care that the sizes of the variable and
  2046. the destination type are the same.
  2047. \item [class type expected]
  2048. The variable of expression isn't of the type \var{class}.
  2049. \item [functions variables of overloaded functions are not allowed]
  2050. You are trying to assign an overloaded function to a procedural variable.
  2051. This isn't allowed.
  2052. \item [can't create assembler file]
  2053. The assembler output file cannot be opened. This can have many causes, but
  2054. 'disk full' is a reasonable guess.
  2055. \item [string length must be a value from 1 to 255]
  2056. The length of a string in Pascal is limited to 255 characters. You are
  2057. trying to declare a string with length greater than 255.
  2058. \item [class identifier expected]
  2059. The variable isn't of type \var{class}.
  2060. \item [method identifier expected]
  2061. This identifier is not a method.
  2062. \item [function header doesn't match any method of this class]
  2063. You are defining a function as a class method, but no such function was
  2064. declared in the class.
  2065. \item [use extended syntax of DISPOSE and NEW to generate instances of classes]
  2066. If you have a pointer \var{a} to a class type, then the statement
  2067. \var{new(a)} will not initialize the class (i.e. the constructor isn't
  2068. called), although space will be allocated. you should issue the
  2069. \var{new(a,init)} statement. This will allocate space, and call the
  2070. constructor of the class.
  2071. \item [file types must be var parameters]
  2072. You cannot specify files as value parameters, i.e. they must always be
  2073. declared \var{var} parameters.
  2074. \item [string exceeds line]
  2075. You forgot probably to include the closing ' in a string, so it occupies
  2076. multiple lines.
  2077. \item [illegal version of the unit:]
  2078. This unit was compiled with an earlier version of \fpc.
  2079. \item [illegal floating point constant]
  2080. \item [destructors can't have parameters]
  2081. You are declaring a destructor with a parameter list. Destructor methods
  2082. cannot have parameters.
  2083. \item [FAIL can be used in constructors only]
  2084. You are using the \var{FAIl} instruction outside a constructor method.
  2085. \item [records fields can be aligned to 1,2 or 4 bytes only]
  2086. You are specifying the \var{\{\$PACKRECORDS n\} } with an illegal value for
  2087. \var{n}. Only 1,2 or 4 are valid in this case.
  2088. \item [too many \$ENDIFs or \$ELSEs]
  2089. Your \var{\{\$IFDEF ..\}} and {\{\$ENDIF\}} statements aren't balanced.
  2090. \item [\$ENDIF expected]
  2091. Your \var{\{\$IFDEF ..\}} and {\{\$ENDIF\}} statements aren't balanced.
  2092. \item [illegal call by reference parameters]
  2093. \item [can't generate DEF file]
  2094. \ostwo only. The DEF file cannot be generated.
  2095. \item [all overloaded methods must be virtual if one is virtual:]
  2096. If you declare overloaded methods in a class, then they should either all be
  2097. virtual, or none. You cannot mix them.
  2098. \item [overloaded methods which are virtual must have the same return type:]
  2099. If you declare virtual overloaded methods in a class definition, they must
  2100. have the same return type.
  2101. \item [all overloaded virtual methods must support exceptions if one support exceptions:]
  2102. If you declare overloaded virtual methods in a class, then they should either
  2103. all support exceptions, or none. You cannot mix them.
  2104. \item [EXPORT declared functions can't be called]
  2105. You are trying to call a procedure you declared as \var{export}. Due to the
  2106. different calling scheme of \fpc and C, you cannot call such a function from
  2107. within your Pascal program.
  2108. \item [EXPORT declared functions can't be nested]
  2109. You cannot declare a function or procedure within a function or procedure
  2110. that was declared as an export procedure.
  2111. \item [methods can't be EXPORTed]
  2112. You cannot declare a procedure that is a method for an object as
  2113. \var{export}ed. That is, you methods cannot be called from a C program.
  2114. \item [SELF is only allowed in methods]
  2115. You are trying to use the \var{self} parameter outside an object's method.
  2116. Only methods get passed the \var{self} parameters.
  2117. \item [call by var parameters have to match exactly]
  2118. When calling a function declared with \var{var} parameters, the variables in
  2119. the function call must be of exactly the same type. There is no automatic
  2120. type conversion.
  2121. \item [class identifier expected]
  2122. The variable isn't of type \var{class}.
  2123. \item [class isn't a super class of the current class]
  2124. When calling inherited methods, you are trying to call a method of a strange
  2125. class. You can only call an inherited method of a parent class.
  2126. \item [methods can be only in other methods called direct with type identifier of the class]
  2127. A construction like \var{sometype.somemethod} is only allowed in a method.
  2128. \item [illegal type: pointer to class expected]
  2129. You specified an illegal type.
  2130. \item [possible illegal call of constructor or destructor (doesn't match to this context)]
  2131. \item [class should have one destructor only]
  2132. You can declare only one destructor for a class.
  2133. \item [expression must be constructor call]
  2134. When using the extended syntax of \var{new}, you must specify the constructor
  2135. method of the class you are trying to create. The procedure you specified
  2136. is not a constructor.
  2137. \item [identifier idents no member]
  2138. When using the extended syntax of \var{new}, you must specify the constructor
  2139. method of the class you are trying to create. The procedure you specified
  2140. does not exist.
  2141. \item [expression must be destructor call]
  2142. When using the extended syntax of \var{dispose}, you must specify the
  2143. destructor method of the class you are trying to dispose of.
  2144. The procedure you specified is not a destructor.
  2145. \item [type conflict between set elements]
  2146. There is at least one set element which is of the wrong type, i.e. not of
  2147. the set type.
  2148. \item [illegal expression in set constructor]
  2149. \item [type conflict between set elements]
  2150. You are specifying elements of a different type for a set.
  2151. \item [illegal use of ':']
  2152. \item [expression type must be class or record type]
  2153. The expression isn't of type class or record.
  2154. \item [the operator / isn't defined for integer, the result will be real, use DIV instead]
  2155. When using the '/' operator in \fpc the result will be of type real, when
  2156. used with integers.
  2157. \item [can't write PPU file]
  2158. There is a problem when writing to the unit file.
  2159. \item [illegal order of record elements]
  2160. When declaring a constant record, you specified the fields in the wrong
  2161. order.
  2162. \item [the name of constructors must be INIT]
  2163. You are declaring a constructor with a name which isn't \var{init}, and the
  2164. \var{-Ss} switch is in effect. See the \var{-Ss} switch (\seeo{Ss}).
  2165. \item [the name of constructors must be DONE]
  2166. You are declaring a constructor with a name which isn't \var{done}, and the
  2167. \var{-Ss} switch is in effect. See the \var{-Ss} switch (\seeo{Ss}).
  2168. \item [set element type mismatch]
  2169. The type of the element doesn't equal the set type.
  2170. \item [illegal label declaration]
  2171. \item [label not found]
  2172. A \var{goto label} was encountered, but the label isn't declared.
  2173. \item [GOTO and LABEL are not supported (use command line switch -Sg)]
  2174. You must compile a program which has \var{label}s and \var{goto} statements
  2175. with the \var{-Sg} switch. By default, \var{label} and \var{goto} aren't
  2176. supported.
  2177. \item [set expected]
  2178. The variable or expression isn't of type \var{set}.
  2179. \item [identifier isn't a label]
  2180. The identifier specified after the \var{goto} isn't of type label.
  2181. \item [label already defined]
  2182. You're attempting to define a label two times. (i.e. you put the same label
  2183. on two different places.)
  2184. \item [label isn't defined:]
  2185. A label was declared, but not defined.
  2186. \item [constructors and destructors must be methods]
  2187. You're declaring a procedure as destructor or constructor, when the
  2188. procedure isn't a class method.
  2189. \item [error when assembling]
  2190. An error occurred when assembling. This can have many causes.
  2191. \item [identifier not used:]
  2192. This is a warning. The identifier was declared (locally or globally) but
  2193. wasn't used (locally or globally).
  2194. \item [functions with void return value can't return any value]
  2195. In \fpc, you can specify a return value for a function when using
  2196. the \var{exit} statement. This error occurs when you try to do this with a
  2197. procedure. Procedures cannot return a value.
  2198. \item [Hmmm..., this code can't be much efficient]
  2199. You construction seems dubious to the compiler.
  2200. \item [unreachable code]
  2201. You specified a loop which will never be executed. Example:
  2202. \begin{verbatim}
  2203. while false do
  2204. begin
  2205. {.. code ...}
  2206. end;
  2207. \end{verbatim}
  2208. \item [This overloaded function can't be local (must be exported)]
  2209. You are defining a overloaded function in the implementation part of a unit,
  2210. but there is no corresponding declaration in the interface part of the unit.
  2211. \item [It's not possible to overload this operator]
  2212. You are trying to overload an operator which cannot be overloaded.
  2213. \item [Abstract methods can't be called direct]
  2214. \fpc understands the \var{abstract} keyword.
  2215. \item [the mix of CLASSES and OBJECTS are not allowed]
  2216. You cannot use \var{object} and \var{class} intertwined.
  2217. \item [macro buffer overflow while reading or expanding a macro]
  2218. Your macro or it's result was too long for the compiler.
  2219. \item [keyword redefined as macro has no effect]
  2220. You cannot redefine keywords with macros.
  2221. \item [extension of macros exceeds a deep of 16,\\ perhaps there is a recursive macro definition (crashes the compiler)]
  2222. When expanding a macro macros have been nested to a level of 16.
  2223. \item [ENDIF without IF(N)DEF]
  2224. Your code contains more \var{\{\$ENDIF\}} than \var{\{\$IF(N)DEF\}}
  2225. statements.
  2226. \item [user defined:]
  2227. A user defined warning occurred. see also the \progref
  2228. \item [linker: Duplicate symbol:]
  2229. Two global symbols in the code have the same name.
  2230. \item [linker: Error while reading object file]
  2231. The linker couldn't read the object file (the assembled file).
  2232. \item [linker: object file not found]
  2233. The linker didn't find the object file (the assembled file).
  2234. \item [linker: illegal magic number in file:]
  2235. The linker cannot determine the type of a file it wants to link in. The type
  2236. of a link file is specified using a magic number, which is some pre-defined
  2237. constant, unique for each system.
  2238. \item [The extended syntax of new or dispose isn't allowed for a class]
  2239. You cannot generate an instance of a class with the extended syntax of
  2240. \var{new}. The constructor must be used for that. For the same reason, you
  2241. cannot call \var{Dispose} to de-allocate an instance of a class, the
  2242. destructor must be used for that.
  2243. \item [To generate an instance of a class or an object with an abstract method isn't allowed]
  2244. You are trying to generate an instance of a class which has an abstract
  2245. method that wasn't overridden.
  2246. \item [Only virtual methods can be abstract]
  2247. You are declaring a method as abstract, when it isn't declared to be
  2248. virtual.
  2249. \item [Abstract methods shouldn't have any definition (with function body)]
  2250. Abstract methods can only be declared, you cannot implement them. They
  2251. should be overridden by a descendant class.
  2252. \item [can't call the assembler]
  2253. An error occurred when calling the assembler.
  2254. \item [can't call o2obj]
  2255. An error occurred when calling the \var{o} to \var{obj} conversion program.
  2256. \item [asm syntax error]
  2257. There is an error in the assembly language.
  2258. \item [register name expected]
  2259. There is an error in the assembly language. The assembler expected a
  2260. register and got something else.
  2261. \item [asm size mismatch]
  2262. There is an error in the assembly language. The sizes of operands and
  2263. registers don't match.
  2264. \item [no instr match,]
  2265. There is an error in the assembly language. An unknown instruction was
  2266. encountered.
  2267. \item [can't compile unit:]
  2268. When trying to do a build, the compiler cannot compile one of the units.
  2269. \item [Re-raise isn't possible there]
  2270. You are trying to raise an exception where it isn't allowed. You can only
  2271. raise exceptions in an \var{except} block.
  2272. \item [ Syntax error while parsing a conditional compiling expression ]
  2273. \item [ Evaluating a conditional compiling expression ]
  2274. There is an error in the expression following the \var{\{\$if \}} compiler
  2275. directive.
  2276. \item [ Keyword redefined as macro has no effect ]
  2277. You cannot redefine Pascal keywords with macros. If you, for instance would
  2278. want to redefine the exit command you'd get this error.
  2279. \item [ compiler switches aren't allowed in (* ... *) styled comments ]
  2280. Compiler switches should always be between \var{\{ \}} comment delimiters.
  2281. \item [ No DLL File specified ]
  2282. \item [ Illegal open parameter ]
  2283. You are trying to use the wrong type for an open parameter.
  2284. \item [ Illegal floating point constant ]
  2285. The compiler expects a floating point expression, and gets something else.
  2286. \item [ string types doesn't match, because of \$V+ mode ]
  2287. When compiling in \var{\{\$V+ \}} mode, the string you pass as a parameter
  2288. should be of the exact same type as the declared parameter of the procedure.
  2289. \item [ Only class methods can be referred with class references ]
  2290. This error occurs in a situation like the following:
  2291. \begin{verbatim}
  2292. Type :
  2293. Tclass = Class of Tobject;
  2294. Var C : TClass;
  2295. begin
  2296. ...
  2297. C.free
  2298. \end{verbatim}
  2299. \var{Free} is not a class method and hence cannot be called with a class
  2300. reference.
  2301. \item [ Only class methods can be accessed in class methods ]
  2302. This is related to the previous error. You cannot call a method of an object
  2303. from a inside a class method. The following code would produce this error:
  2304. \begin{verbatim}
  2305. class procedure tobject.x;
  2306. begin
  2307. free
  2308. \end{verbatim}
  2309. Because free is a normal method of a class it cannot be called from a class
  2310. method.
  2311. \item [ Constant and CASE types do not match ]
  2312. One of the labels is not of the same type as the case variable.
  2313. \item [ The symbol can't be exported from a library ]
  2314. You can only export procedures and functions when you write a library. You
  2315. cannot export variables or constants.
  2316. \item [ A virtual method must be overridden using the OVERRIDE directive: ]
  2317. A method that is declared \var{virtual} in a parent class, should be
  2318. overridden in the descendent class with the \var{override} directive. If you
  2319. don't specify the \var{override} directive, you will hide the parent method;
  2320. you will not override it.
  2321. \item [ There is no method in an ancestor class to be overridden: ]
  2322. You try to \var{override} a virtual method of a parent class that doesn't
  2323. exist.
  2324. \item [ No member is provided to access property ]
  2325. You specified no \var{read} directive for a property.
  2326. \item [ Illegal symbol for property access ]
  2327. There is an error in the \var{read} or \var{write} directives for an array
  2328. property. When you declare an array property, you can only access it with
  2329. procedures and functions. The following code woud cause such an error.
  2330. \begin{verbatim}
  2331. tmyobject = class
  2332. i : integer;
  2333. property x [i : integer]: integer read I write i;
  2334. \end{verbatim}
  2335. \item [ Cannot write a protected field of an object ]
  2336. Fields that are declared in a \var{protected} section of an object or class
  2337. declaration cannot be accessed outside that objects methods.
  2338. \item [ range check error in set constructor or duplicate set element ]
  2339. The declaration of a set contains an error. Either one of the elements is
  2340. outside the range of the set type, either two of the elements are in fact
  2341. the same.
  2342. \item [ Pointer to class expected ]
  2343. The compiler expects a reference to a class.
  2344. \item [ Operator is not overloaded ]
  2345. You're trying to use an overloaded operator when it isn't overloaded for
  2346. this type.
  2347. \item [ Variable or type indentifier expected ]
  2348. \item [ Assembler incompatible with function return value ]
  2349. You're trying to implement a \var{assembler} function, but the return type
  2350. of the function doesn't allow that.
  2351. \item [ Procedure overloading is switched off ]
  2352. You're trying to compile overloaded procedures with the \var{-So} (Turbo Pascal
  2353. compatibility) switch. Remove the switch.
  2354. \item [ Comparative operator must return a boolean value ]
  2355. When overloading the \var{=} operator, the function must return a boolean
  2356. value.
  2357. \item [ Use of unsupported feature! ]
  2358. You're trying to force the compiler into doing something it cannot do yet.
  2359. \item [ absolute can only be associated to ONE variable ]
  2360. You cannot specify more than one variable before the \var{absolute} directive.
  2361. Thus, the following construct will provide this error:
  2362. \begin{verbatim}
  2363. Var Z : Longint;
  2364. X,Y : Longint absolute Z;
  2365. \end{verbatim}
  2366. \item [ absolute can only be associated a var or const ]
  2367. The address of a \var{absolute} directive can only point to a variable or
  2368. constant. Therefore, the following code will produce this error:
  2369. \begin{verbatim}
  2370. Procedure X;
  2371. var p : longint absolute x;
  2372. \end{verbatim}
  2373. \item [ succ or pred on enums with assignments not possible ]
  2374. When you declared an enumeration type which has assignments in it, as in C,
  2375. like in the following:
  2376. \begin{verbatim}
  2377. Tenum = (a,b,e:=5);
  2378. \end{verbatim}
  2379. you cannot use the \var{Succ} or \var{Pred} functions on them.
  2380. \item [ Array properties aren't allowed at this point ]
  2381. Indexed properties are not yet implemented.
  2382. \item [ No property found to override ]
  2383. You want to overrride a property of a parent class, when there is, in fact,
  2384. no such property in the parent class.
  2385. \item [ Only one default property is allowed, found inherited default property in class ]
  2386. You specified a property as \var{Default}, but a parent class already has a
  2387. default property, and a class can have only one default property.
  2388. \item [ The default property must be an array property ]
  2389. Only array properties of classes can be made \var{default} properties.
  2390. \item [ Internal Error in SymTableStack() ]
  2391. An internal error occurred in the compiler; If you encounter such an error,
  2392. please contact the developers and try to provide an exact description of
  2393. the circumstances in which the error occurs.
  2394. \item [ Error in type definition ]
  2395. There is an error in your definition of a new type.
  2396. \item [ Only static variables can be used in static methods or outside methods ]
  2397. A static method of an object can only access static variables.
  2398. \item [ Invalid call to tvarsym.mangledname() ]
  2399. An internal error occurred in the compiler; If you encounter such an error,
  2400. please contact the developers and try to provide an exact description of
  2401. the circumstances in which the error occurs.
  2402. \item [ illegal type declaration of set elements ]
  2403. The declaration of a set contains an invalid type definition.
  2404. \item [ Forward class definition not resolved ]
  2405. You declared a class, but you didn't implement it.
  2406. \item [ identifier idents no member ]
  2407. You specify a field of a record or object, and the record or object doesn't
  2408. contains such a field.
  2409. \item [ The use of a far pointer isn't allowed there ]
  2410. Free Pascal doesn't support far pointers, so you cannot take the address of
  2411. an expression which has a far reference as a result. The \var{mem} construct
  2412. has a far reference as a result, so the following code will produce this
  2413. error:
  2414. \begin{verbatim}
  2415. var p : pointer;
  2416. ...
  2417. p:=@mem[a000:000];
  2418. \end{verbatim}
  2419. \item [ procedure call with stackframe ESP/SP ]
  2420. A procedure doesn't need a complete stack-frame, so it is omitted.
  2421. \item [ Abstract methods can't be called directly ]
  2422. You cannot call an abstract method directy, instead you must call a
  2423. overriding child method, because an abstract method isn't implemented.
  2424. \item [ Internal Error in getfloatreg(), allocation failure ]
  2425. An internal error occurred in the compiler; If you encounter such an error,
  2426. please contact the developers and try to provide an exact description of
  2427. the circumstances in which the error occurs.
  2428. \item [ Unknown float type ]
  2429. The compiler cannot determine the kind of float in an expression.
  2430. \item [ SecondVecn() base defined twice ]
  2431. An internal error occurred in the compiler; If you encounter such an error,
  2432. please contact the developers and try to provide an exact description of
  2433. the circumstances in which the error occurs.
  2434. \item [ Extended cg68k not supported ]
  2435. \item [ 32-bit unsigned not supported in MC68000 mode ]
  2436. The cardinal type isn't supported on the MC68000 processor.
  2437. \item [ Internal Error in secondinline() ]
  2438. An internal error occurred in the compiler; If you encounter such an error,
  2439. please contact the developers and try to provide an exact description of
  2440. the circumstances in which the error occurs.
  2441. \item [ Stack limit excedeed in local routine ]
  2442. Your code requires a too big stack. Some operating systems pose limits
  2443. on the stack size. You should use less variables or try ro put large
  2444. variables on the heap.
  2445. \end{description}
  2446. \chapter{Run time errors}
  2447. The \fpc Run-tim library generates the following errors at run-time
  2448. \footnote{The \linux port will generate only a subset of these.}:
  2449. \begin{description}
  2450. \item [1 Invalid function number]
  2451. You tried to call a \dos function which doesn't exist.
  2452. \item [2 File not found]
  2453. You can get this error when you tried to do an operation on a file which
  2454. doesn't exist.
  2455. \item [3 Path not found]
  2456. You can get this error when you tried to do an operation on a file which
  2457. doesn't exist, or when you try to change to, or remove a directory that doesn't exist,
  2458. or try to make a subdirectory of a subdirectory that doesn't exist.
  2459. \item [4 Too many open files]
  2460. When attempting to open a file for reading or writing, you can get this
  2461. error when your program has too many open files.
  2462. \item [5 File access denied]
  2463. You don't have access to the specified file.
  2464. \item [6 Invalid file handle]
  2465. If this happens, the file variable you are using is trashed; it
  2466. indicates that your memory is corrupted.
  2467. \item [12 Invalid file access code]
  2468. This will happen if you do a reset or rewrite of a file when \var{FileMode}
  2469. is invalid.
  2470. \item [15 Invalid drive number]
  2471. The number given to the Getdir function specifies a non-existent disk.
  2472. \item [16 Cannot remove current directory]
  2473. You get this if you try to remove the current diirectory.
  2474. \item [17 Cannot rename across drives]
  2475. You cannot rename a file such that it would end up on another disk or
  2476. partition.
  2477. \item [100 Disk read error]
  2478. \dos only. An error occurred when reading from disk. Typically when you try
  2479. to read past the end of a file.
  2480. \item [101 Disk write error]
  2481. \dos only. Reported when the disk is full, and you're trying to write to it.
  2482. \item [102 File not assigned]
  2483. This is reported by Reset, Rewrite, Append, Rename and Erase, if you call
  2484. them with an unassigne function as a parameter.
  2485. \item [103 File not open]
  2486. Reported by the following functions : Close , Read, Write, Seek,
  2487. EOf, FilePos, FileSize, Flush, BlockRead, and BlockWrite if the file isn't
  2488. open.
  2489. \item [104 File not open for input]
  2490. Reported by Read, BlockRead, Eof, Eoln, SeekEof or SeekEoln if the file
  2491. isn't opened with Reset.
  2492. \item [105 File not open for output]
  2493. Reported by write if a text file isn't opened with Rewrite.
  2494. \item [106 Invalid numeric format]
  2495. Reported when a non-numerice value is read from a text file, when a numeric
  2496. value was expected.
  2497. \item [150 Disk is write-protected]
  2498. (Critical error, \dos only.)
  2499. \item [151 Bad drive request struct length]
  2500. (Critical error, \dos only.)
  2501. \item [152 Drive not ready]
  2502. (Critical error, \dos only.)
  2503. \item [154 CRC error in data]
  2504. (Critical error, \dos only.)
  2505. \item [156 Disk seek error]
  2506. (Critical error, \dos only.)
  2507. \item [157 Unknown media type]
  2508. (Critical error, \dos only.)
  2509. \item [158 Sector Not Found]
  2510. (Critical error, \dos only.)
  2511. \item [159 Printer out of paper]
  2512. (Critical error, \dos only.)
  2513. \item [160 Device write fault]
  2514. (Critical error, \dos only.)
  2515. \item [161 Device read fault]
  2516. (Critical error, \dos only.)
  2517. \item [162 Hardware failure]
  2518. (Critical error, \dos only.)
  2519. \item [200 Division by zero]
  2520. You are dividing a number by zero.
  2521. \item [201 Range check error]
  2522. If you compiled your program with range checking on, then you can get this
  2523. error in the following cases:
  2524. \begin{enumerate}
  2525. \item An array was accessed with an index outside its declared range.
  2526. \item You're trying to assign a value to a variable outside its range (for
  2527. instance a enumerated type).
  2528. \end{enumerate}
  2529. \item [202 Stack overflow error]
  2530. The stack has grown beyond itss maximum size. This error can easily occur if
  2531. you have recursive functions.
  2532. \item [203 Heap overflow error]
  2533. The heap has grown beyond its boundaries, ad you are rying to get more
  2534. memory. Please note that \fpc provides a growing heap, i.e. the heap will
  2535. try to allocate more memory if needed. However, if the heap has reached the
  2536. maximum size allowed by the operating system or hardware, then you will get
  2537. this error.
  2538. \item [204 Invalid pointer operation]
  2539. This you will get if you call dispose or Freemem with an invalid pointer
  2540. (notably, \var{Nil})
  2541. \item [205 Floating point overflow]
  2542. You are trying to use or produce too large real numbers.
  2543. \item [206 Floating point underflow]
  2544. You are trying to use or produce too small real numbers.
  2545. \item [207 Invalid floating point operation]
  2546. Can occur if you try to calculate the square root or logarithm of a negative
  2547. number.
  2548. \item [210 Object not initialized]
  2549. When compiled with range checking on, a program will report this error if
  2550. you call a virtal method without having initialized the VMT.
  2551. \item [211 Call to abstract method]
  2552. Your program tried to execute an abstract virtual method. Abstract methods
  2553. should be overridden, and the overriding method should be called.
  2554. \item [212 Stream registration error]
  2555. This occurs when an invalid type is registered in the objects unit.
  2556. \item [213 Collection index out of range]
  2557. You are trying to access a collection item with an invalid index.
  2558. (objects unit)
  2559. \item [214 Collection overflow error]
  2560. The collection has reached its maximal size, and you are trying to add
  2561. another element. (objects unit)
  2562. \item [216 General Protection fault]
  2563. You are trying to access memory outside your appointed memory.
  2564. \end{description}
  2565. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2566. % Assembler reader errors
  2567. \section{Assembler reader errors.}
  2568. This section lists the errors that are generated by the inline assembler reader.
  2569. They are {\em not} the messages of the assembler itself.
  2570. % General assembler errors.
  2571. \subsection{General assembler errors}
  2572. \begin{description}
  2573. \item [Divide by zero in asm evaluator]
  2574. This fatal error is reported when a constant assembler expressions
  2575. does a division by zero.
  2576. \item [Evaluator stack overflow, Evaluator stack underflow]
  2577. These fatal errors are reported when a constant assembler expression
  2578. is too big to evaluate by the constant parser. Try reducing the
  2579. number of terms.
  2580. \item [Invalid numeric format in asm evaluator]
  2581. This fatal error is reported when a non-numeric value is detected
  2582. by the constant parser. Normally this error should never occur.
  2583. \item [Invalid Operator in asm evaluator]
  2584. This fatal error is reported when a mathematical operator is detected
  2585. by the constant parser. Normally this error should never occur.
  2586. \item [Unknown error in asm evaluator]
  2587. This fatal error is reported when an internal error is detected
  2588. by the constant parser. Normally this error should never occur.
  2589. \item [Invalid numeric value]
  2590. This warning is emitted when a conversion from octal,binary or hexadecimal
  2591. to decimal is outside of the supported range.
  2592. \item [Escape sequence ignored]
  2593. This error is emitted when a non ANSI C escape sequence is detected in
  2594. a C string.
  2595. \item [Asm syntax error - Prefix not found]
  2596. This occurs when trying to use a non-valid prefix instruction
  2597. \item [Asm syntax error - Trying to add more than one prefix]
  2598. This occurs when you try to add more than one prefix instruction
  2599. \item [Asm syntax error - Opcode not found]
  2600. You have tried to use an unsupported or unknown opcode
  2601. \item [Constant value out of bounds]
  2602. This error is reported when the constant parser determines that the
  2603. value you are using is out of bounds, either with the opcode or with
  2604. the constant declaration used.
  2605. \item [Non-label pattern contains @]
  2606. This only applied to the m68k and Intel styled assembler, this is reported
  2607. when you try to use a non-label identifier with a '@' prefix.
  2608. \item [Internal error in Findtype()]
  2609. \item [Internal Error in ConcatOpcode()]
  2610. \item [Internal Errror converting binary]
  2611. \item [Internal Errror converting hexadecimal]
  2612. \item [Internal Errror converting octal]
  2613. \item [Internal Error in BuildScaling()]
  2614. \item [Internal Error in BuildConstant()]
  2615. \item [internal error in BuildReference()]
  2616. \item [internal error in HandleExtend()]
  2617. \item [Internal error in ConcatLabeledInstr()]
  2618. \label{InternalError}
  2619. These errors should never occur, if they do then you have found
  2620. a new bug in the assembler parsers. Please contact one of the
  2621. developers.
  2622. \item [Opcode not in table, operands not checked]
  2623. This warning only occurs when compiling the system unit, or related
  2624. files. No checking is performed on the operands of the opcodes.
  2625. \item [@CODE and @DATA not supported]
  2626. This Turbo Pascal construct is not supported.
  2627. \item [SEG and OFFSET not supported]
  2628. This Turbo Pascal construct is not supported.
  2629. \item [Modulo not supported]
  2630. Modulo constant operation is not supported.
  2631. \item [Floating point binary representation ignored]
  2632. \item [Floating point hexadecimal representation ignored]
  2633. \item [Floating point octal representation ignored]
  2634. These warnings occur when a floating point constant are declared in
  2635. a base other then decimal. No conversion can be done on these formats.
  2636. You should use a decimal representation instead.
  2637. \item [Identifier supposed external]
  2638. This warning occurs when a symbol is not found in the symolb table, it
  2639. is therefore considered external.
  2640. \item [Functions with void return value can't return any value in asm code]
  2641. Only routines with a return value can have a return value set.
  2642. \item [Error in binary constant]
  2643. \item [Error in octal constant]
  2644. \item [Error in hexadecimal constant]
  2645. \item [Error in integer constant]
  2646. \label{ErrorConst}
  2647. These errors are reported when you tried using an invalid constant expression,
  2648. or that the value is out of range.
  2649. \item [Invalid labeled opcode]
  2650. \item [Asm syntax error - error in reference]
  2651. \item [Invalid Opcode]
  2652. \item [Invalid combination of opcode and operands]
  2653. \item [Invalid size in reference]
  2654. \item [Invalid middle sized operand]
  2655. \item [Invalid three operand opcode]
  2656. \item [Assembler syntax error]
  2657. \item [Invalid operand type]
  2658. You tried using an invalid combination of opcode and operands, check the syntax
  2659. and if you are sure it is correct, please contact one of the developers.
  2660. \item [Unknown identifier]
  2661. The identifier you are trying to access does not exist, or is not within the
  2662. current scope.
  2663. \item [Trying to define an index register more than once]
  2664. \item [Trying to define a segment register twice]
  2665. \item [Trying to define a base register twice]
  2666. You are trying to define an index/segment register more then once.
  2667. \item [Invalid field specifier]
  2668. The record or object field you are trying to access does not exist, or
  2669. is incorrect.
  2670. \item [Invalid scaling factor]
  2671. \item [Invalid scaling value]
  2672. \item [Scaling value only allowed with index]
  2673. Allowed scaling values are 1,2,4 or 8.
  2674. \item [Cannot use SELF outside a method]
  2675. You are trying to access the SELF identifier for objects outside a method.
  2676. \item [Invalid combination of prefix and opcode]
  2677. This opcode cannot be prefixed by this instruction
  2678. \item [Invalid combination of override and opcode]
  2679. This opcode cannot be overriden by this combination
  2680. \item [Too many operands on line]
  2681. At most three operand instructions exist on the m68k, and i386, you
  2682. are probably trying to use an invalid syntax for this opcode.
  2683. \item [Duplicate local symbol]
  2684. You are trying to redefine a local symbol, such as a local label.
  2685. \item [Unknown label identifer]
  2686. \item [Undefined local symbol]
  2687. \item [local symbol not found inside asm statement]
  2688. This label does not seem to have been defined in the current scope
  2689. \item [Assemble node syntax error]
  2690. \item [Not a directive or local symbol]
  2691. The assembler statement is invalid, or you are not using a recognized
  2692. directive.
  2693. \end{description}
  2694. % I386 specific errors
  2695. \subsection{I386 specific errors}
  2696. \begin{description}
  2697. \item [repeat prefix and a segment override on <= i386 may result in errors if an interrupt occurs]
  2698. A problem with interrupts and a prefix instruction may occur and may cause
  2699. false results on 386 and earlier computers.
  2700. \item [Fwait can cause emulation problems with emu387]
  2701. This warning is reported when using the FWAIT instruction, it can
  2702. cause emulation problems on systems which use the em387.dxe emulator.
  2703. \item [You need GNU as version >= 2.81 to compile this MMX code]
  2704. MMX assembler code can only be compiled using GAS v2.8.1 or later.
  2705. \item [NEAR ignored]
  2706. \item [FAR ignored]
  2707. \label{FarIgnored}
  2708. \var{NEAR} and \var{FAR} are ignored in the intel assemblers, but are still accepted
  2709. for compatiblity with the 16-bit code model.
  2710. \item [Invalid size for MOVSX/MOVZX]
  2711. \item [16-bit base in 32-bit segment]
  2712. \item [16-bit index in 32-bit segment]
  2713. 16-bit addressing is not supported, you must use 32-bit addressing.
  2714. \item [Constant reference not allowed]
  2715. It is not allowed to try to address a constant memory address in protected
  2716. mode.
  2717. \item [Segment overrides not supported]
  2718. Intel style (eg: rep ds stosb) segment overrides are not support by
  2719. the assembler parser.
  2720. \item [Expressions of the form [sreg:reg...] are currently not supported]
  2721. To access a memory operand in a different segment, you should use the
  2722. sreg:[reg...] snytax instead of [sreg:reg...]
  2723. \item [Size suffix and destination register do not match]
  2724. In intel AT\&T syntax, you are using a register size which does
  2725. not concord with the operand size specified.
  2726. \item [Invalid assembler syntax. No ref with brackets]
  2727. \item [ Trying to use a negative index register ]
  2728. \item [ Local symbols not allowed as references ]
  2729. \item [ Invalid operand in bracket expression ]
  2730. \item [ Invalid symbol name: ]
  2731. \item [ Invalid Reference syntax ]
  2732. \item [ Invalid string as opcode operand: ]
  2733. \item [ Null label references are not allowed ]
  2734. \item [ Using a defined name as a local label ]
  2735. \item [ Invalid constant symbol ]
  2736. \item [ Invalid constant expression ]
  2737. \item [ / at beginning of line not allowed ]
  2738. \item [ NOR not supported ]
  2739. \item [ Invalid floating point register name ]
  2740. \item [ Invalid floating point constant: ]
  2741. \item [ Asm syntax error - Should start with bracket ]
  2742. \item [ Asm syntax error - register: ]
  2743. \item [ Asm syntax error - in opcode operand ]
  2744. \item [ Invalid String expression ]
  2745. \item [ Constant expression out of bounds ]
  2746. \item [ Invalid or missing opcode ]
  2747. \item [ Invalid real constant expression ]
  2748. \item [ Parenthesis are not allowed ]
  2749. \item [ Invalid Reference ]
  2750. \item [ Cannot use \_\_SELF outside a method ]
  2751. \item [ Cannot use \_\_OLDEBP outside a nested procedure ]
  2752. \item [ Invalid segment override expression ]
  2753. \item [ Strings not allowed as constants ]
  2754. \item [ Switching sections is not allowed in an assembler block ]
  2755. \item [ Invalid global definition ]
  2756. \item [ Line separator expected ]
  2757. \item [ Invalid local common definition ]
  2758. \item [ Invalid global common definition ]
  2759. \item [ assembler code not returned to text ]
  2760. \item [ invalid opcode size ]
  2761. \item [ Invalid character: < ]
  2762. \item [ Invalid character: > ]
  2763. \item [ Unsupported opcode ]
  2764. \item [ Invalid suffix for intel assembler ]
  2765. \item [ Extended not supported in this mode ]
  2766. \item [ Comp not supported in this mode ]
  2767. \item [ Invalid Operand: ]
  2768. \item [ Override operator not supported ]
  2769. \end{description}
  2770. % m68k specific errors
  2771. \subsection{m68k specific errors.}
  2772. \begin{description}
  2773. \item [Increment and Decrement mode not allowed together]
  2774. You are trying to use dec/inc mode together.
  2775. \item [Invalid Register list in movem/fmovem]
  2776. The register list is invalid, normally a range of registers should
  2777. be separated by - and individual registers should be separated by
  2778. a slash.
  2779. \item [Invalid Register list for opcode]
  2780. \item [68020+ mode required to assemble]
  2781. \end{description}
  2782. \chapter{The Floating Point Coprocessor emulator}
  2783. In this appendix we note some caveats when using the floating point
  2784. emulator on GO32V2 systems. Under GO32V1 systems, all is as described in
  2785. the installation section.
  2786. {\em Q: I don't have an 80387. How do I compile and run floating point
  2787. programs under GO32V2?
  2788. Q: What shall I install on a target machine which lacks hardware
  2789. floating-point support?
  2790. }
  2791. {\em A :}
  2792. Programs which use floating point computations and could be run on
  2793. machines without an 80387 should be allowed to dynamically load the
  2794. \file{emu387.dxe}
  2795. file at run-time if needed. To do this you must link the \var{emu387} unit to your
  2796. exectuable program, for example:
  2797. \begin{verbatim}
  2798. Program MyFloat;
  2799. Uses emu387;
  2800. var
  2801. r: real;
  2802. Begin
  2803. r:=1.0;
  2804. WriteLn(r);
  2805. end.
  2806. \end{verbatim}
  2807. \var{Emu387} takes care of loading the dynamic emulation point library.
  2808. You should always add emulation when you distribute floating-point
  2809. programs.
  2810. A few users reported that the emulation won't work for them unless
  2811. they explicitly tell \var{DJGPP} there is no \var{x87} hardware, like this:
  2812. \begin{verbatim}
  2813. set 387=N
  2814. set emu387=c:/djgpp/bin/emu387.dxe
  2815. \end{verbatim}
  2816. There is an alternative FP emulator called WMEMU. It mimics a real
  2817. coprocessor more closely.
  2818. {\em WARNING:} We strongly suggest that you use WMEMU as FPU emulator, since
  2819. \file{emu387.dxe} does not emulate all the instructions which are used by the
  2820. Run-Time Libary such as \var{FWAIT}.
  2821. {\em Q: I have an 80387 emulator installed in my AUTOEXEC.BAT, but
  2822. DJGPP-compiled floating point programs still doesn't work. Why?
  2823. }
  2824. {\em A :} DJGPP switches the CPU to protected mode, and the information
  2825. needed to emulate the 80387 is different. Not to mention that the
  2826. exceptions never get to the real-mode handler. You must use emulators
  2827. which are designed for DJGPP. Apart of emu387 and WMEMU, the only
  2828. other emulator known to work with DJGPP is Q87 from QuickWare. Q87 is
  2829. shareware and is available from the QuickWare Web site.
  2830. {\em Q: I run DJGPP in an \ostwo DOS box, and I'm told that \ostwo will install
  2831. its own emulator library if the CPU has no FPU, and will transparently
  2832. execute FPU instructions. So why won't DJGPP run floating-point code
  2833. under \ostwo on my machine?
  2834. }
  2835. {\em A} : \ostwo installs an emulator for native \ostwo images, but does not
  2836. provide FPU emulation for DOS sessions.
  2837. \chapter{A sample \file{gdb.ini} file}
  2838. \label{ch:GdbIniFile}
  2839. Here you have a sample \file{gdb.ini} file listing, which gives better
  2840. results when using \var{gdb}. Under \linux you should put this in a
  2841. \file{.gdbinit} file in your home directory or the current directory..
  2842. \begin{verbatim}
  2843. set print demangle off
  2844. set gnutarget auto
  2845. set verbose on
  2846. set complaints 1000
  2847. dir ./rtl/dosv2
  2848. set language c++
  2849. set print vtbl on
  2850. set print object on
  2851. set print sym on
  2852. set print pretty on
  2853. disp /i $eip
  2854. define pst
  2855. set $pos=&$arg0
  2856. set $strlen = {byte}$pos
  2857. print {char}&$arg0.st@($strlen+1)
  2858. end
  2859. document pst
  2860. Print out a pascal string
  2861. end
  2862. \end{verbatim}
  2863. \end{document}