Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

Example: Caching temporary source files

The Windows DDK (Driver Development Kit) suggests that you use a Build Utility to compile and link the provided source code:

http://msdn.microsoft.com/en-us/library/ff556163.aspx

The Build Utility generates temporary source files and uses them to create a precompiled header (PCH) for a specific project. When generation of the precompiled header is complete, the temporary source files are deleted.

Let's say you are building a project, test, with the precompiled header, test.h. The Build Utility creates a temporary source file named pch_hdr.src:

-- file: pch_hdr.src
    #include "test.h"

This file is used as an input to the compiler to generate the precompiled header test.pch, and is then deleted.

kwinject and kwwrap intercept this kind of compiler call and write an appropriate record to the build specification. The problem is that when your build is complete, the generated build specification references a nonexistent source file. Hence, if you try to generate a build specification, or directly use the build specification to run the build, you will not be able to access this type of source file, and your Klocwork analysis will fail.

To resolve this issue, kwinject has a cached sources mechanism. Use the --cache-files <pattern>[,<pattern>...] option of kwinject. This option will save source files matching any of the specified patterns. For example:

kwinject --cache-files "*.src" build -zcg