NI LabWindows™/CVI™ 2009 Help
Edition Date: November 2009
Part Number: 370051P-01
»View Product Info
You can set the LabWindows/CVI compiler options by selecting Options»Build Options in the Workspace window. This command opens a dialog box in which you can set the following LabWindows/CVI compiler options:
- Default calling convention (32-bit)—Sets the compiler's default calling convention for 32-bit projects. The default calling convention is normally __cdecl but can be changed to __stdcall. Do not change the default calling convention to __stdcall if you plan to generate static library or object files.
The calling convention for 64-bit projects is __fastcall. You cannot use __fastcall as the calling convention for 32-bit projects.
 |
Note If you want to create an object file, static library file, or DLL that exports functions with the __stdcall calling convention, it is a good idea to explicitly declare the functions as __stdcall in the include (.h) file and the source (.c) file rather than relying on the Default calling convention option. If you do not explicitly declare the functions as __stdcall in the include file and if another developer uses the object file, library file, or DLL in LabWindows/CVI or an external compiler without setting the default calling convention to __stdcall, the functions do not work correctly. |
- Maximum stack size (bytes)—Adjusts the maximum stack size in the program.
Your program uses the stack for passing function parameters and storing automatic local variables. By setting a stack limit, LabWindows/CVI can catch infinitely recursive functions and report a stack overflow. If you enable the Detect uninitialized local variables at run time option in this dialog box, LabWindows/CVI uses extra stack space. You can adjust your maximum stack size to avoid a stack overflow.
- Image base address—Specifies the address where LabWindows/CVI loads a DLL or executable into memory. By specifying the image base address, you can avoid relocating DLLs, which can slow down the load time of DLLs. You also can avoid collisions, which occur when LabWindows/CVI attempts to load more than one DLL with the same address.
You can specify any value, or you can select the following default values:
- x00400000 for 32-bit executables
- x10000000 for 32-bit DLLs
- x0000000000400000 for 64-bit executables
- x0000000010000000 for 64-bit DLLs
- Profiling—Sets the profiling level in your application.
 |
Note You must have the LabWindows/CVI Execution Profiler Toolkit installed to take advantage of this option. |
- Disabled—Disables profiling.
- User functions—Profiles only the user-defined functions in the application.
- User functions and other calls—Profiles the user-defined functions and calls to other library objects that have source in a project that is not built with profiling enabled. For example, other calls might include calls to LabWindows/CVI functions, Interface to Win32 Applciation Programmatic Interface (API), and so on.
- Debugging level—Sets the debugging level in your application. LabWindows/CVI uses this setting only if you enable the Build»Configuration»Debug item of the Workspace window. If you enable the Build»Configuration»Release item, LabWindows/CVI compiles all source files (*.c) without debugging information.
Select one of the three debugging levels for the source modules in your application.
- No run-time checking—In this level, you can set breakpoints and use the Variables window. You have no protection from run-time memory errors, and you cannot use the Run»Break on»Library Errors option.
- Standard—In this level, you can set breakpoints, use the Variables window, and use the Run»Break on»Library Errors option. You also have protection from run-time memory errors.
- Extended—This level has the same benefits as Standard mode, with added user protection that validates every attempt to free dynamically allocated memory by verifying that the address you pass is actually the beginning of an allocated block.
Select this level to enable resource tracking by default. Resource tracking is available only in the LabWindows/CVI Full Development System.
- Detect uninitialized local variables at run time—Checks for the run-time use of variables that do not have values assigned to them. Enabling this option causes LabWindows/CVI to use extra stack space. To avoid a stack overflow, adjust the maximum stack size.
- Track include file dependencies—Keeps the project up-to-date by tracking the dependencies between source files and include files. Whenever you modify a file, LabWindows/CVI marks for compilation all source files that include the modified file.
- Prompt for include file paths—Prompts you to make a manual search for any header files listed in the #include lines that the compiler cannot find. When you find them, you can automatically insert the appropriate path into the Include Paths list for the project.
- Compile with precompiled include file—Precompiles frequently used header files to decrease compile time.
- Maximum number of compile errors—Sets an upper limit on the number of compile errors that LabWindows/CVI lists in the Build Output window for each source file.
- Stop on first file with errors—Sets the LabWindows/CVI compiler to terminate compilation after it finds one file with errors. Using this option, you can correct build errors in your project one file at a time.
- Show build output window for warnings—Sets the LabWindows/CVI compiler to open the Build Output window when warnings occur, even if no errors exist. If you deactivate this option, warnings can occur without being brought to your attention.
- Uninitialized local variables detection—Generates error messages when you access variables that do not have values assigned to them. You can select the following levels:
- Disabled—This mode disables uninitialized local variable warnings and errors.
- Conservative—This mode flags only variables that do not have values assigned to them.
- Aggressive—This mode flags all variables that may or may not have values assigned to them.
- Detect signed/unsigned pointer mismatches—Generates a compiler warning for pointer assignments in which the left side and right side are not both signed or unsigned expressions. According to the ANSI C standard, these assignments are errors because they involve incompatible types. In practice, however, such assignments cause no problems.
The LabWindows/CVI compiler checks assignment statements and function call arguments to ensure that the lvalue and rvalue expressions have compatible types. If you enable this option, LabWindows/CVI generates compile warnings when the lvalue and rvalue expressions are both pointers to integers but one points to a signed integer and the other points to an unsigned integer. For example, the LabWindows/CVI compiler generates a signed type mismatch between pointer to char and pointer to unsigned char warning on the call to MyFunction in the following code:
void MyFunction (unsigned char *x);
char *y = "my string";
main () {
MyFunction (y);
}
- Detect unreachable code—Generates a compiler warning for statements that the compiler cannot reach on execution. When you enable this option, the LabWindows/CVI compiler generates a warning at each line of code that cannot be reached during the execution of your program. For example, LabWindows/CVI reports a warning on the break statement in the following code:
switch (intval) {
case 4:
return 0;
break;
}
- Detect unreferenced identifiers—Generates compiler warnings for identifiers that are not referenced in your program.
- Detect assignments in conditional expressions—Directs LabWindows/CVI to check for possible errors in conditional expressions that can make the conditional expression an assignment.
- Require function prototypes—Requires you to precede all function references with a full prototype declaration. A full prototype includes the function return type and the types of each parameter. If a function has no parameters, a full prototype must have the void keyword to indicate this case. A new style function definition (one in which you declare parameters directly in the parameter list) can serve as a prototype.
Missing prototype errors can occur at the following places:
- Typedefs such as typedef void FUNTYPE()
- Function pointer declarations such as void (*fp)() whether used as a global, local, parameter, array element, or structure member
- Old style function definitions, in which you declare parameters outside of the parameter list, that you do not precede with a full prototype
- Function call expressions such as (*fp)(), where fp does not have a full prototype
 |
Caution It is best to enable the Require function prototypes option. If disabled, some of the run-time error checking also is disabled. |
- Require return values for non-void functions—This option generates compile warnings for non-void functions, except main, that do not end with a return statement that returns a value. LabWindows/CVI reports a run-time error when a non-void function executes without returning a value.
For example, the following code always produces a compile-time warning, and it produces a run-time error when flag is FALSE.
int fun (void)
{
if (flag) {
return 0;
}
}
- Build with C99 extensions—Specifies whether LabWindows/CVI compiles the project with C99 extensions enabled.
In specific sections of your code, you can override this project-wide setting by using the associated pragmas in the source code.
 |
Note C99 extensions might not be supported in external compilers. |
- Display status dialog during build—Displays a status dialog box during the build that shows the name of the file being compiled, the number of errors and warnings encountered, and a percent completed value. The project compiles faster when you disable this feature.
- Make 'O' option compatible with CVI 5.0.1—Enables the 'O' option to perform as it did in LabWindows/CVI 5.0.1. LabWindows/CVI compiles the source file without debugging information and writes the .obj file to disk in the same directory as the source file. To set a file with the 'O' option, right-click a file in the Project Tree and select Enable 'O' Option from the context menu.
- Generate source code browse information—Displays source code browse information under Window»Source Code Browser.
- Active Compiler—Specifies which compiler configuration to use for release configuration compiles. Click the … button to the right of this option to open the Compiler for Release Configuration dialog box, which you can use to modify the list of available configurations.
- Compiler Defines—Sets compiler defines.
- Predefined Macros—Lists the predefined macros.