Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
50
Добавлен:
14.04.2015
Размер:
1.37 Mб
Скачать

18

Chapter 2. Compiling with the Cx51 Compiler

 

 

SET C51INC=C:\KEIL\C51\INC

SET C51LIB=C:\KEIL\C51\LIB

Running Cx51 from the Command Prompt

To invoke the C51 or CX51 compiler, enter C51 or CX51 at the command prompt. On this command line, you must include the name of the C source file

2 to be compiled, as well as any other necessary control directives required to compile your source file. The format for the Cx51 command line is:

C51 sourcefile directives…

CX51 sourcefile directives…

or:

C51 @commandfile

CX51 @commandfile

where:

sourcefile is the name of the source program you want to compile.

directives are the directives you want to use to control the function of the compiler. Refer to “Control Directives” on page 20 for a detailed list of the available directives.

commandfile is the name of a command input file that may contain sourcefile and directives. A commandfile is used, when the Cx51 invocation line gets complex and exceeds the limits of the Windows command prompt.

The following command line example invokes C51, specifies the source file SAMPLE.C, and uses the controls DEBUG, CODE, and PREPRINT.

C51 SAMPLE.C DEBUG CODE PREPRINT

The Cx51 compiler displays the following information upon successful compilation.

C51 COMPILER V6.10

C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)

Keil Software — Cx51 Compiler User’s Guide

19

 

 

ERRORLEVEL

After compilation, the number of errors and warnings detected is output to the screen. The Cx51 compiler then sets the ERRORLEVEL to indicate the status of the compilation. Values are listed in the following table:

 

ERRORLEVEL

Meaning

 

2

 

0

No errors or warnings

 

 

1

Warnings only

 

 

2

Errors and possibly warnings

 

 

 

 

 

3

Fatal errors

 

 

You can access the ERRORLEVEL variable in batch files. Refer to the Windows command index or to batch commands in the Windows on-line help for more information on ERRORLEVEL or batch files.

Cx51 Output Files

The Cx51 compiler generates a number of output files during compilation. By default, each of these output files shares the same filename as the source file. However, each has a different file extension. The following table lists the files and gives a brief description of each.

File Extension

Description

filename.LST

Files with this extension are listing files that contain the formatted source

 

text along with any errors detected by the compiler. Listing files may

 

optionally contain the symbols used and the assembly code generated.

 

For more information, refer to the PRINT directive in the following sections.

filename.OBJ

Files with this extension are object modules that contain relocatable object

 

code. Object modules may be linked to an absolute object module by the

 

Lx51 Linker/Locator.

filename.I

Files with this extension contain the source text as expanded by the

 

preprocessor. All macros are expanded and all comments are deleted in

 

this listing. For more information, refer to the PREPRINT directive in the

 

following sections.

filename.SRC

Files with this extension are assembly source files generated from your C

 

source code. These files can be assembled with the A51 assembler. For

 

more information, refer to the SRC directive in the following sections.

Соседние файлы в папке HLP