user.tex 105 KB

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