user.tex 122 KB

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