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:
- Compatibility with—This option displays the current compiler compatibility mode. You can change the current compatible compiler by selecting Visual C/C++ or Borland C/C++. You must restart LabWindows/CVI after changing the compiler compatibility.
- Default calling convention—This option sets the compiler's default calling convention. For both compilers, 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 for both compatible external compilers.
 |
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)—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, LabWindows/CVI uses extra stack space. You can adjust your maximum stack size to avoid a stack overflow.
- Image base address—This option 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 executables
- x10000000 for DLLs
- Debugging level—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 mode, 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 mode, 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 mode 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.
- Detect uninitialized local variables at run time—This option 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—This option 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—This option sets LabWindows/CVI to prompt 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.
- Display status dialog during build—This option 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—When you enable this option, the 'O' option performs 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.
- Uninitialized local variables detection—This option 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—This option 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—This option 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—This option generates compiler warnings for identifiers that are not referenced in your program.
- Detect assignments in conditional expressions—LabWindows/CVI checks for possible errors in conditional expressions that can make the conditional expression an assignment.
- Require function prototypes—This option 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;
}
}
- Maximum number of compile errors—This option 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—This option 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—This option 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.
- Generate source code browse information—Use this option to view source code browse information under Window»Source Code Browser.
- Active Compiler—Use this option to specify 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—Use this option to set compiler defines.
- Predefined Macros—This option lists the predefined macros.