Precompiled Headers
- Updated2023-02-21
- 3 minute(s) read
Precompiled Headers
Decrease the amount of time required to compile a large project by using precompiled headers. Instead of compiling header files repeatedly, you can include a prefix header file that references frequently used header files. LabWindows/CVI precompiles the header files listed in the prefix header file. To ensure that you do not have to precompile the prefix header file often, include in the prefix header file only system header files and header files that do not frequently change.
Complete the following steps to use precompiled headers in a LabWindows/CVI project.
- Create and save a prefix header file.
You also can use the cviincludes.h prefix header file in the cvi\include directory. If you want to make changes to the cviincludes.h file, you must save a copy of the file and make changes in the copy.
![]() |
Note The files in cviincludes.h are common LabWindows/CVI header files. |
- Include the prefix header file in the LabWindows/CVI project.
If you use the cviincludes.h file as it is, you do not need to add cviincludes.h to the project. - Enable the Compile with precompiled include file option in the Build Options dialog box.
- Select the prefix header file you want to use from the pull-down menu.
- Click the OK button to save the changes and exit the Build Options dialog box.
The next time LabWindows/CVI compiles the project, LabWindows/CVI compiles the prefix header file first and then compiles the remaining files. In subsequent compilations, LabWindows/CVI loads the precompiled header file instead of the header files listed in the prefix header file. The amount of compile time you save using precompiled headers depends on the size of the header files you include and the size of the source files.
Caveats for Using Prefix Header Files
Consider the following caveats when using a prefix header file.
- Adapt the prefix header file to the needs of your project; add and remove header files as necessary.
For example, if you use a copy of the cviincludes.h file and the file includes header files you do not use in your project, remove those header files to increase the speed of the initial compilation and reduce the amount of time required to load the precompiled header file.
![]() |
Note Do not modify the cviincludes.h file directly. Make a copy of the cviincludes.h file and modify the copy. |
- Keep in mind that certain header files must be compiled in a particular order.
For example, LabWindows/CVI must compile windows.h before all other header files. If you initially do not use windows.h in your application, you might remove that header file from the prefix header file to decrease compilation time. If you remove windows.h, you cannot add it to the source files later because the source files are compiled after the precompiled headers. You must add it back to the prefix header file to preserve precedence and avoid build errors.