• Aucun résultat trouvé

Command·line compiler

Dans le document for OS/2® (Page 114-119)

As an alternative to using the IDE, you can compile and run your programs with the command-line compiler (BCC.EXE). Almost anything you can do within the IDE can also be done using the command-line compiler. You can tum specific warnings on or off, invoke TASM (or another assembler) to assemble .ASM source files, invoke the linker to generate executable files, and so on.

This chapter is organized into two parts:

• The first part describes how to use the command-line compiler and provides a table of command-line compiler options along with a page-number cross-reference to where you can find detailed information about each option (see Table 6.1 starting on page 106).

a The second part, starting on page 111, presents the options organized functionally (with groups of related options).

To invoke Borland C++ from the command line, type BCC at the OS/2 shell prompt and follow it with a set of command-line arguments. Command-line arguments include compiler and linker options and file names. The generic command-line format is

BCC [option [option ... ]] filename [filename ... ]

Each command-line option must be preceded by either a hyphen (-) or slash (I), whichever you prefer. Each option must be separated by at least one space from the BCC command, other options, and file names that follow.

The options are divided into three general types:

• Compiler options, described starting on page 111.

a Linker options, described starting on page 124.

• Environment options, described starting on page 125.

To see an onscreen list of the options, type BCC (without any options or file names) at the OS/2 prompt, then press Enter.

Chapter 6, Command-line compiler 105

Use this feature to override settings in configuration files.

Option precedence rules

To select command-line options, enter a hyphen (-) or slash (I) imme-diately followed by the option letter (for example, -lor II). To set an option off, add a second hyphen after the option letter. This is true for all toggle options (those that set an option on or off): A trailing hyphen (-) sets the option off, and a trailing plus sign (+) or nothing sets it on. So, for example, -C and -C+ both set nested comments on, while -C- sets nested comments off.

The option precedence rules are simple; command-line options are evaluated from left to right, and the following rules apply:

• For any option that is not an -lor -L option, a duplication on the right overrides the same option on the left. (Thus an off option on the right cancels an on option to the left.)

• The -I and -L options on the left, however, take precedence over those on the right.

Table 6.1: Command-line options summary Option Page Description

@filename 110 Read compiler options from the response file filename.

+ filename 110 Use the alternate configuration file filename.

-A 116 Use only ANSI keywords with strict compliance checking.

-A- 116 Use Borland C++ keywords (default).

-AT 116 Use Borland C++ keywords (default).

-AK 117 Use only Kernighan and Ritchie keywords.

-AU 117 Use only UNIX keywords.

-an 113 Align to n: 1 = Byte, 2 = VVord, 4 = Double Word boundaries.

-a- 113 Align byte (default).

-B 120 Compile and call the assembler to process inline assembly code.

-b 113 Make enums always int-sized (default).

-b- 113 Make enums byte-sized or word-sized when possible.

-C 117 Nested comments on.

-C- 117 Nested comments off (default).

-c 120 Compile to .OBJ but do not link.

-Dname 112 Define name to the null string.

-D name=string 112 Define name to string.

-d 113 Merge duplicate strings on.

-d- 113 Merge duplicate strings off (default).

-Efilename 120 Use filename as the assembler to use.

-efilename 124 Link to produce filename.EXE.

-ff 113 Fast floating point (default).

-ff- 113 Strict ANSI floating point.

Table 6.1: Command-line options summary (continued)

-G 136 Select code for speed.

-G- 136 Select code for size (default).

-gn 117 Warnings: stop after n messages.

-H 120 Causes the compiler to generate and use precompiled headers.

-H- 120 Turns off generation and use of precompiled headers (default).

-Hc 120 Cache precompiled headers. Must be used with -H or -Hxxx.

-Hu 120 Tells the compiler to use but not generate precompiled headers.

-H"xxx" 121 Stop compiling precompiled headers at file "xxx". This must be used with -H, -Hu, or -H=filename.

-H=filename 120 Sets the name of the file for precompiled headers.

-Ipath 125 Directories for include files.

-in 117 Make significant identifier length to be n.

-Jg 123 Generate definitions for all template instances and merge duplicates (default).

-Jgd -Jgx

123 123

Generate public definitions for all template instances; duplicates result in redefinition errors.

Generate external references for all template instances.

-jn 117

Errors: stop after n messages.

Default character type unsigned.

Default character type signed (default).

Allow only two character types (unsigned and signed); char is treated as signed char.

Allows compatibility with Borland C++ 1.0.

Standard stack frame on (default).

Standard stack frame off.

Directories for libraries.

Pass option xto the linker (can use more than one x).

Suppress option x for the linker.

InstruCt the linker to create a map. file.

Check for stack overflow.

Set the output directory.

Optimize for speed.

Optimize for size.

Assume that pointer expressions are not aliased in common subexpression evaluation.

Eliminate stores into dead variables.

Enable local optimizations performed on blocks of code with single entry and single exit. The optimizations performed are common subexpression elimination, code reordering, branch optimizations, copy propagation, constant folding and code compaction.

Disable all optimizations, except jump distance optimization, which the compiler performs automatically.

Enable global register allocation and data flow analysis.

Enable all optimizations that perform transformations within an entire function, including global common subexpression elimination, loop invariant code motion, induction variable elimination, linear function test replacement, loop compaction and copy propagation.

Enable inlining of intrinsic functions such as memcpy, str/en, and so on.

Attempts to minimize code size.

Chapter 6, Command-line compiler 107

Table 6.1: Command-line options summary (continued)

Attempts to maximize application execution speed.

Enables most speed optimizations (provided for Microsoft compatibility).

Compile source file to filename.obj.

Perform a Ctt compile regardless of source file extension.

Perform a Ctt compile and set the default extension to ext.

Perform a Ctt or C compile depending on source file extension (default).

Perform a Ctt or C compile depending on extension; set default extension to ext.

Use Pascal L -pascal) calling convention.

Use standard L _stdcall) calling convention (default).

Use C L _cdecl) calling convention.

Use register L Jastcall) calling convention for passing parameters in registers.

Enable register variables (default).

Suppress the use of register variables.

Include browser information in generated .OBJ files.

Enable run-time type information.

Produce .ASM output file.

Specify the name for the linker to use as the module definition file.

Link as a DLL.

Link with the multiple-thread libraries (*MT.LlB).

Pass string as an option to TASM or assembler specified with -E.

Remove all previous assembler options.

Undefine any previous definitions of name.

Generate underscores (default).

Disables underscores.

Smart Ctt virtual tables.

External Ctt virtual tables.

Public Ctt virtual tables.

Use the smallest representation for member pointers.

Member pointers support multiple inheritance.

Honor the declared precision for all member pointer types.

Member pointers support single inheritance.

Member pointers have no restrictions (most general representation).

Local Ctt virtual tables.

Source debugging on.

Source debugging off.

Turns expansion of inline functions on.

Turns expansion of inline functions off.

Display warnings on.

Enable warning message xxx.

Disable warning message xxx.

Disable compiler autodependency output.

Enable exception handling.

Enable destructor cleanup.

Table 6.1: Command-line options summary (continued)

-xf 124 Expand function exception handling initialization inline.

-xp 124 Enable exception location information.

-y 115 Line numbers on.

Far virtual table segment.

Far virtual table.

Use default name for X (default).

c++ files have the extension .CPP; see page 121 for information on changing the default extension.

Borland C++ compiles files according to the following set of rules:

• FILENAME.ASM Invoke TASM to assemble to .OBJ.

• FILENAME.OBJ

Include as object at link time.

Include as library at link time.

Compile FILENAME.CPP . Compile FILENAME.CPP.

Compile FILENAME.C.

Compile FILENAME.XYZ.

For example, suppose you have the following command line:

BCC -a -ff- -c -emyexe oldfilel oldfile2 nextfile

Borland C++ compiles OLDFILEl.CPP, OLDFILE2.CPP, and

NEXTFILE.CPP to an .OBJ, linking them to produce an executable program file named MYEXE.EXE with word alignment (-a), strict ANSI fioating-point (-ff-), and nested comments (-C).

Chapter 6, Command-line compiler 109

Dans le document for OS/2® (Page 114-119)