C Compilation: Comparing C and C++ Builds

VisualAge C++ supports incremental build for C++ code, and provides an IDE that you can use to develop C and C++ code. If you are programming in C, you should be aware of the following differences between the way VisualAge C++ handles C and C++ source code.

C Compilation and Incremental C++ Builds
The C compiler takes C source files as input and, if compilation is successful, creates object files. Like most compilers, it processes source files one at a time and creates an object file from scratch for every source that it compiles.

An incremental C++ build uses a program database called the codestore to record information from your C++ source files and configuration file. If you modify your source files, subsequent builds recompile and relink only the portions of code affected by the changes. Therefore, incremental C++ builds can rebuild much faster than traditional compile and link.

The C compiler is not incremental. A VisualAge C++ build from C source files records the include hierarchy and information from the configuration file in the codestore. It stores no other information about your C source code in the codestore. On subsequent builds, an entire C source file is recompiled if it or a file that it includes has a later timestamp than on the previous build.

You cannot use incremental compilation for C source files or incremental linking on code generated from C source code. However, you can use a number of features that are not available with incremental build. For example, the following actions are possible only for C source files:

Order of Declarations in C and C++ Source
You must include header files in every C source file that requires them, and ensure that functions, variables, and the like are declared before they are used. VisualAge C++ frees the C++ programmer from this constraint, by performing orderless compilation. VisualAge C++ processes all C++ source files together and searches in the codestore for declarations when they are required.

Mixing C and C++ Source
In your configuration file, you can explicitly specify whether each source file contains C or C++ source code, or accept the default type set by the file extension. VisualAge C++ runs the C compiler for C source files or incorporates code for C++ source files into the codestore. If you have both C and C++ source files in one build, the linker links the object files compiled from C source files with the code in the codestore generated from C++ source files.

Using the IDE
You can use the VisualAge C++ IDE to develop C code and C++ code. You can enter and edit source files for either language with the Editor, in a Source view. You can compile and link by clicking the Build button. Use the Project SmartGuide to create your configuration file and the Configuration section of the IDE to modify it.

Not all of the IDE works the same for C and C++. For example, the browsing and debugging features use the representation of C++ code that is stored in the codestore and do not apply to C code.

For both C and C++, you see compile and link messages in a Message view of the IDE. Messages are sent to the console when you build with the vacbld command.

Debugging C Code
To debug C code, use a traditional debugger such as the debuggers supplied with earlier versions of VisualAge C++ and predecessor products. Build with options gen(debug) or gen(lineOnlyDebug) to include debugger information in your object and executable files.



Projects
Incremental C++ Build
Configuration Files
Debugging with VisualAge C++
Messages Produced by Builds


Add or Change Source Files
Override the Default Type of a Source File
Add or Change Targets
Set Build Options
Build


Types of Source Files
Build Options