Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
UNITS
In mikroPascal PRO for AVR, each project consists of a single project file and one
or more unit files. Project file, with extension .mppav contains information about the
project, while unit files, with extension .mpas, contain the actual source code.
Units allow you to:
- break large programs into encapsulated parts that can be edited separately, 
- create libraries that can be used in different projects, 
- distribute libraries to other developers without disclosing the source code. 
Each unit is stored in its own file and compiled separately. Compiled units are linked
to create an application. In order to build a project, the compiler needs either a
source file or a compiled unit file (.mcl file) for each unit.
Uses Clause
mikroPascal PRO for AVR includes units by means of the uses clause. It consists of
the reserved word uses, followed by one or more comma-delimited unit names, fol-
lowed by a semicolon. Extension of the file should not be included. There can be at
most one uses clause in each source file, and it must appear immediately after the
program (or unit) name.
Here’s an example:
uses utils, strings, Unit2, MyUnit;
For the given unit name, the compiler will check for the presence of 
.mcl
and 
.mpas
files, in order specified by the search paths.
- If both 
.mpas 
and
.mcl
files are found, the compiler will check their dates and 
include the newer one in the project. If the 
.mpas
file is newer than 
.mcl
, a new 
library will be written over the old one; 
- If only 
.mpas
file is found, the compiler will create the 
.mcl
file and include it in the 
project; 
- If only 
.mcl
file is present, i.e. no source code is available, the compiler will include 
it as it is found; 
- If none found, the compiler will issue a “File not found” warning. 
133
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroPASCAL PRO for AVR
CHAPTER 5