Source File or User Code has Changed; Rebuild Environment Before Instrumenting for Code Coverage

Issue:

While building a new environment, I see a dialog pop-up indicating that
 

The source file <some fully qualified path to a file in the source tree> or user code for that unit has changed since the environment was built. Rebuild the environment before instrumenting for code coverage.

Solution:

This message appears when the output from the preprocessor differs even when the files have not changed. This could be due to the use of __DATE__ or __TIME__ macros in your source code or headers #included by your source code. Do you use any macros like that? What compiler are you using? In the past I have had customers successfully got past this problem by inserting something like the following in unit prefix user code:
 

#undef __DATE__
#undef __TIME__
#define __DATE__ "Jan 01 2001"
#define __TIME__ "01:01:01"

 

In rare instances, this message may also appear if preprocess and/or compile command contains flags that manipulate your unit(s) under test. For example, for a GNU ARM compiler, adding a -g3 flag to either command will add all of the #defines that the compiler is using to the top of the file. This is a problem because when the compare for instrumentation is done, it looks to compare the .tu.c file (done at the beginning) with the .tu.c.preproc file (done right before instrumentation). Depending on your settings, the macro VCAST_SBF_UNITS_AVAILABLE may be available in the latter file, but not the original file prompting the error indicating that the unit has changed. The simple solution here is to remove the offending flag from the preprocess and compile commands.
 



Article ID: 1502
Last updated: 2019-11-07
Revision: 4
VectorCAST -> Troubleshooting -> Source File or User Code has Changed; Rebuild Environment Before Instrumenting for Code Coverage
https://kb.vector.com/entry/1502/