Although P-Code has its advantages, the capability to compile to native code
is an advantage that most VB6 programmers put to good use, especially because
it permits additional optimizations. This discussion focuses on the basic compiler
options for native code.
Visual Basic versions 5 and 6 have the capability to compile native machine
code into the EXE files it produces. Like the applications normally produced with
other language compilers that produce Windows programs (for example, Visual C++),
VB programs require library files. The difference is that a compiler such as Visual
C++ can create completely independent EXEs—if the programmer is willing
to write all the program’s interface code from the ground up. VB can’t
do that.
Why is native code important? You already know the answer: speed. As hardware
has become faster and operating systems have grown more sophisticated, programmers
feel the need to produce applications that can keep pace. In a world in which
desktop computers featuring 200+MHz Pentium processor chips and 32MB+ RAM are
becoming commonplace, and developers routinely produce Internetenabled programs,
your applications absolutely must be fast if they are to be taken seriously.
To compile to native code, open the Project Properties dialog box and make
sure that the Compile to Native Code option button is selected. When you do, additional
choices on the dialog box become available. The following sections look at these
choices.
-
Basic Optimizations
Optimizing for Fast Code
Optimizing for Small Code, No Optimization
Favoring Pentium Pro, Creating Symbolic Debug
Info
Results of Basic Optimization
-
Advanced Optimizations
Assuming No Aliasing
Removing Array Bounds Checks
Removing Integer Overflow Checks, Removing Floating-Point
Error Checks
Allowing Unrounded Floating-Point Operations,
Removing Safe Pentium FDIV Checks