RAD Studio
BCC32, the C++ Command-Line Compiler

The CodeGear C++ compiler (BCC32.EXE) is a resource compiler shell. It invokes BRCC32 and RLINK32, depending on the command-line syntax.

bcc32 [option [option...}] <filename> [<filename>...] 

Use spaces to separate the command-line compiler name, each option, and the filenames. Precede each option by either a hyphen (-) or a forward slash (/). For example: 

BCC32 -Ic:\code\hfiles 

You can also specify options in configuration (.CFG) files, which are described in a following section.  

You can use BCC32 to send .OBJ files to ILINK32 or .ASM files to TASM32 (if you have TASM32 installed on your machine).

See the BCC32 Command Line Help for Detailed Information

To display the BCC32.exe command line help in the cmd window, include the —h command line option. 

For example, to display a list of the commonly used compiler command line options, type:  

BCC32 -h  

The displayed list indicates the options that are enabled by default (*):

C:\>bcc32 -h CodeGear C++ 5.92 for Win32 Copyright (c) 1993, 2007 CodeGear 
Available options (* = default setting, xxx = has sub-options: use -h -X): 
(Note: -X- or -w-XXX will usually undo whatever was set or unset by -X) 
  -3      Generate 80386 protected-mode compatible instructions 
  -4      Generate 80386/80486 protected-mode compatible instructions 
  -5      Generate Pentium instructions 
  -6      Generate Pentium Pro instructions 
  -Axxx   Enable ANSI conformance 
  -B      Compile to .ASM (-S), then assemble to .OBJ 
  -C      Enable nested comments 
  -CP     Enable code paging (for MBCS) 
  -D      -D <name> defines 'name' as a null string, or use -D<name>=<value> 
  -E      Specify which assembler to use 
  -G      Optimize for size/speed; use -O1 and -O2 instead 
  -Hxxx   Generate and use precompiled headers 
  -I      Set the include file search path 
  -Jxxx   Template generation options 
  -K      Set default character type to unsigned 
  -L      Library file search path 
  -M      Create a linker map file 
  -O      Optimize jumps 
  -P      Perform C++ compile regardless of source extension 
  -Q      Extended compiler error information 
  -R      Include browser information in generated .OBJ files 
  -RF     Find references to symbol 
* -RT     Enable runtime type information 
  -S      Compile to assembly 
  -T      Specify assembler option, e.g. -Tx 
  -U      Undefine any previous definitions of name 
  -Vxxx   Compatibility options 
  -Wxxx   Target is a Windows application 
  -X      Disable compiler autodependency output 
  -axxx   Set data alignment boundary.  Default is -a8; -a- means -a1 
* -b      Make enums integer-sized (-b- makes them short as possible) 
  -c      Compile to object file only, do not link 
  -d      Merge duplicate strings 
  -dc     Put strings into the read-only data segment 
  -dw     Put strings into the (writeable) data segment 
  -e      Specify target executable pathname 
* -ff     Fast floating point 
  -fp     Correct Pentium FDIV flaw 
* -fq     Use quiet floating point compare instruction (FUCOMP) 
  -g      Stop batch compilation after n warnings (Default = 255) 
  -h      Request help ('-h -' shows all help). Can be specific: -h -V 
  -i      Set maximum significant identifier length (Default = 250) 
  -j      Stop batch compilation after n errors (Default = None) 
* -k      Generate standard stack frames 
  -l      Pass options to the linker; example: -ls -l-x 
  -m      Generate makefile dependency information 
  -md     Put dependency info in .d files, not in the object file 
  -mm     Ignore system header files while generating dependency info 
  -mo     Specify the output file for dependency info 
  -n      Set output directory for object files 
  -o      Set output filename (-o<filename> or —o <filename> supported)
  -pxxx   Use Pascal calling convention 
  -q      Suppress compiler identification banner 
  -r      Use register variables 
  -rd     Use register variables only when register keyword is employed 
  -s      Link using the system's non-incremental linker 
  -txxx   An alternate name for the -Wxxx switches; there is no difference 
* -u      Generate underscores on symbol names 
  -vxxx   Turn on source debugging 
  -w      Display all warnings 
  -w!     Return non-zero from compiler on warnings 
  -xxxx   Enable exception handling 
  -y      Debug line numbers on 
  -z      Options for redefining standard segment names


Displaying Help for Specific Options, Groups such as -Axxx and -Vxxx

You can get more specific information about each of the multi-letter options, such as -Axxx (language compatibility and standards compliance) and -Vxxx (backward compatibility). 

To do this, use the -h command line option with the initial letter of the option group (such as -A to specify the -Axxx options). BCC32 will display only the help topics for the specified set of options (such as —Axxx, —Vxxx or —Wxxx).  

For example, to display a description of the -Axxx (language compatibility and standards compliance) options, use the —h and —A command line options:

C:\>bcc32 -h -A
CodeGear C++ 6.10 for Win32 Copyright (c) 1993-2008 CodeGear
Available options (* = default setting, xxx = has sub-options: use -h -X):
(Note: -X- or -w-XXX will usually undo whatever was set or unset by -X)
  -A      Enable ANSI conformance
  -AF     Use SUN Forte keywords and extensions
  -AG     Use GNU keywords and extensions
  -AK     Use Kernighan and Ritchie keywords and extensions
  -AT     Use CodeGear C++ keywords and extensions (also -A-)
  -AU     Use UNIX System V keywords and extensions
  -An     Use C99 keywords and extensions
  -Ax     Use C++-0x keywords and extensions

In the following example, the BCC32 command line help displays details about all the -Vxxx (backward compatibility) options:

C:\>bcc32 -h -V
CodeGear C++ 6.10 for Win32 Copyright (c) 1993-2008 CodeGear
Available options (* = default setting, xxx = has sub-options: use -h -X):
(Note: -X- or -w-XXX will usually undo whatever was set or unset by -X)
  -V      Compatibility options
  -V0     External C++ virtual tables
  -V1     Public C++ virtual tables
* -VA     Generate all global functions in their own virtual/weak segment
  -VC     Do not mangle calling convention into symbols
  -VF     MFC compatibility
  -VF3    Support MFC 3.2
  -VF4    Support MFC 4.0
* -VI     Use Microsoft search algorithm to locate header files
  -VM     Microsoft Visual C++ compatibility
  -Va     Support old-style class arguments
  -Vb     Enable backward compatability with Bcc versions 5.8.2 and earlier
  -Vbc    Don't collapse reference to reference and allow qualified references
  -Vbe    Allow old-style explicit template specialization
  -Vbn    Allow calling of non-const or non-volatile member function for a const
 or volatile object
  -Vbo    Use old Borland overload resolution rules
  -Vbr    Allow non-const reference binding
  -Vbs    Treat string literals as non-const
  -Vbt    Use old Borland type rules for ternary operators
  -Vbx    Allow explicit template specialization as a member function
  -Vc     Support constructor displacements
  -Vd     Use old C++ for-statement scoping rules
  -Ve     Zero-length empty base classes
  -Vg     Disable lexical digraph scanner
  -Vi     Use old 8.3 search algorithm to locate header files
  -Vl     Use old Borland class layout
  -Vm     Member pointer options
  -Vmd    Use the smallest possible representation for member pointers
  -Vmm    Support multiple inheritance for member pointers
  -Vmp    Honor declared precision of member pointers
  -Vms    Support single inheritance for member pointers
  -Vmv    Place no restrictions on where member pointers can point
  -Vn     Enable new operator names: and, or, and_eq, bitand, etc.
  -Vo     Set (almost) all compatibility flags; used with old code
  -Vp     Push 'this' first, as does Pascal
  -Vr     Reverse order for Multi-character constant
  -Vs     Use old-style virdef generation
  -Vt     Put virtual table pointer at front of object layout
  -Vv     Use 'slow' virtual base pointers
  -Vw     Emit native code instead of Unicode for multi-byte character
  -Vx     Zero-length empty class member functions


Default Settings

BCC32.EXE has specific options that are on by default. To turn off a default option or to override options in a configuration file, follow the option with a minus (-) sign. 

Files with the .CPP extension compile as C++ files. Files with a .C extension, with no extension, or with extensions other than .CPP, .OBJ, .LIB, or .ASM compile as C files.  

The compiler tries to link with a module-definition file with the same name as the executable, and extension .DEF.  

General Compiler Output Options  

Compiles to .OBJ, no link  
Compiles and assembles the named .C, .CPP, and .ASM files, but does not execute a link on the resulting .OBJ files.  
-e <filename>  
Specify executable filename  
Link file using <filename> as the name of the executable file. If you do not specify an executable name with this option, the linker creates an executable file based on the name of the first source file or object file listed in the command.  
-l <x>  
Pass option to linker.  
Use this command-line option to pass option(s) <x> to the linker from a compile command. Use the command-line option -l-x to disable a specific linker option.  
Create a MAP file  
Use this compiler option to instruct the linker to create a map file.  
-o <filename>  
Compike .OBJ to <filename>  
Compiles the specified source file to <filename>.OBJ  
C++ compile  
Causes the compiler to compile all source files as C++ files, regardless of their extension. Use ‑P‑ to compile all .CPP files as C++ source files and all other files as C source files.
The command-line option -Pext causes the compiler to compile all source files as C++ files and it changes the default extension to whatever you specify with ext. This option is provided because some programmers use different extensions as their default extension for C++ code.
The option -P-ext compiles files based on their extension (.CPP compiles to C++, all other extensions compile to C) and sets the default extension (other than .CPP).  
Generate a multi-threaded target  
Creates a multi-threaded .EXE or .DLL. This option is not needed if you include a module definition file (.DEF file) in your compile and link commands which specify the type of 32-bit application you intend to build.  


Compiler option precedence rules

The command-line compilers evaluate options from left to right, and follow these rules:

  • If you duplicate any option (except for the options -D, -I, -L, or -U), the last option typed overrides any earlier one.
  • Options typed at the command line override configuration and response file options except for the ‑D, ‑I, ‑L, and ‑U options, which are cumulative.

Specifying directories in command line options

The CodeGear C++ compiler can search multiple directories for include and library files. The syntax for the library directories option (-L) and the include directories option (-I), (like the #define option (-D)) allows multiple listings of a given option. Here is the syntax for these options:

-L <dirname> [<dirname>;...]
-I <dirname> [<dirname>;...]

The parameter <dirname> used with -L and -I can be any directory or directory path. You can enter these multiple directories on the command line in the following ways

  • You can stack multiple entries with a single -L or -I option by using a semicolon: BCC32.EXE —L dirname1;dirname2;dirname3 —I include1;include2;include3 myfile.c
  • You can place more than one of each option on the command line, like this: BCC32.EXE —L dirname1 —L dirname2 —L dirname3 —I include1 —I include2 —I include3 myfile.c
  • You can mix styles: BCC32.EXE —L dirname1;dirname2 —Ldirname3 —I include1;include2 —I include3 myfile.c
If you list multiple -L or -I options on the command line, the result is cumulative. The compiler searches all the directories listed, in order from left to right.

Using compiler configuration files (.CFG files)

If you repeatedly use a certain set of options, you can list them in a configuration file instead of continually typing them on the command line. A configuration file is a standard ASCII text file that contains one or more command-line options. Each option must be separated by a space or a new line.  

Whenever you issue a compile command, BCC32.EXE searches for a configuration file called BCC32.CFG. The compiler looks for the .CFG file first in the directory where you issue the compile command, then in the directory where the compiler is located.  

You can create and use multiple configuration files in addition to using the default .CFG file.  

To use a configuration file, use the following syntax where you would place the compiler options: 


For example, you could use the following command line to use a configuration file called MYCONFIG.CFG:  

BCC32 +C:\MYPROJ\MYCONFIG.CFG mycode.cpp  

Options typed on the command line override settings stored in configuration files except for the prepended options ‑D, ‑I, ‑L, and ‑U.

Using response files

Response files let you list both compiler options and file names in a single file (unlike configuration files, which accept only compiler options). A response file is a standard ASCII text file that contains one or more command-line options and/or file names, with each entry in the file separated by a space or a new line. In addition to simplifying your compile commands, response files let you issue a longer command line than most operating systems allow.  

The syntax for using a single response file is:  

BCC32 @[path]respfile.txt  

The syntax for using multiple response files is:  

BCC32 @[path]respfile.txt @[path]otheresp.txt  

Response files typically have an .RSP extension.  

Options typed at the command line override any option or file name in a response file except for ‑D, ‑I, ‑L, and ‑U, which are prepended.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!