Overview
Siemens WinCC Cross Reference is the central usage-tracing tool inside the WinCC Explorer and the TIA Portal engineering environments. It indexes tag, picture, CScript standard function, CScript project function, and faceplate references so engineers can answer two questions during commissioning, refactoring, and validation:
- Where used — which other project objects consume a selected object?
- What used — which external objects does a selected object consume?
Beginning with WinCC V7.5 SP2, the Cross Reference GUI correctly resolves tag and PDL picture references inside CScript bodies as long as the source includes the standard header APDIALOG.h. The tool, however, does not index calls to CScript standard or project functions from within other CScripts or from picture event handlers in V7.5 SP2. This article documents the exact reproduction, root cause, V7.5 workarounds, and the V8.1 native solution that resolves the limitation through the new text-based Project Search engine.
Problem Symptoms
The defect manifests under the following configuration:
- A project contains at least one project function (file
*.fct) that calls two standard functions. - A start picture contains a button whose
OnClickevent calls the project function and the two standard functions directly. - The Cross Reference tool is opened with one of the called functions selected as the object filter.
Observed behavior on WinCC V7.5 SP2 Update 16:
- Tag references inside the CScripts are indexed correctly because the standard header
#include "APDIALOG.h"is present. - Picture references inside the CScripts are indexed correctly.
- Cross Reference shows zero usage for the project function called from another project function (function-to-function chain).
-
Cross Reference shows zero usage for standard functions called from the picture
OnClickevent handler. - The expected user result — a list of every script and picture invoking the selected function — is missing.
The same project opened in WinCC V8.1 returns at least two usage entries for each called function: the picture event handler and the calling project function.
Root Cause Analysis
The Cross Reference engine in WinCC V7.5 SP2 performs a token-based parse of compiled project artifacts. Its parser recognizes three classes of objects during the compile step:
| Object Class | V7.5 SP2 Indexer Coverage | V8.1 Indexer Coverage |
|---|---|---|
| Tags (process variables) | Full when APDIALOG.h is included |
Full |
| Pictures (PDL files) | Full | Full |
| CScript standard functions called from pictures | Not indexed | Indexed |
| CScript project functions called from pictures | Not indexed | Indexed |
| CScript function calls nested inside other CScripts | Not indexed | Indexed via Project Search |
| Faceplate type instances | Full | Full |
The V7.5 SP2 indexer does not emit tokens for FunctionCall opcodes emitted by the CScript compiler. It only emits tokens for tag accesses (GetTag, SetTag) and picture references that survive through the APDIALOG.h macro layer. V8.1 introduces a text-based project search engine that scans the CScript source text and updates the Cross Reference database, which is why the same picture shows the call sites correctly in V8.1.
Verification Procedure
To reproduce the issue deterministically on an engineering station:
- Open WinCC Explorer with a WinCC V7.5 SP2 Update 16 project.
- Create a new project function
PF_Demo()in the project function tree. - Insert two calls inside
PF_Demo():#include "APDIALOG.h" void PF_Demo() { SF_StandardOne(); // standard function call SF_StandardTwo(); // standard function call } - Add a button to the start picture and bind the
OnClickevent to:#include "APDIALOG.h" void OnClick(char* lpszPictureName, char* lpszObjectName) { PF_Demo(); SF_StandardOne(); SF_StandardTwo(); } - Compile the project (Project → Compile or right-click → Compile).
- Open the Cross Reference tool (Tools → Cross Reference).
- Select Project functions from the left-hand object tree.
- Tick
PF_Demoand the two standard functions. - Inspect the right-hand usage pane. The pane will be empty even though the project compiled without warnings.
The same procedure executed on WinCC V8.1 returns at least two usage entries per function (the project-function caller and the picture OnClick event).
Workarounds for WinCC V7.5 SP2
Three field-proven workarounds restore function-level traceability without migrating to V8.1.
Workaround A — Project-wide text search
Use the Windows command-line search inside the project folder to enumerate every file referencing a function name:
findstr /S /I /M "PF_Demo" "C:\Projects\MyWinCC\*.c" "C:\Projects\MyWinCC\*.pas"
This produces a flat list of files but loses script context. Pair the output with the call-site location reported in the script editor's Find All References (Ctrl+Shift+F) to recover line and column information.
Workaround B — Manual call-site matrix
Maintain a function-call matrix in a project documentation spreadsheet. The matrix lists, for every CScript function, the parent function or picture event that invokes it. Update the matrix in the same change-set as the source files. Treat the matrix as a peer artifact of the CScript source under source control.
Workaround C — Wrapper macro pattern
Wrap every project function call inside a no-op tag access. The wrapper forces the V7.5 indexer to emit a token because tag accesses are indexed:
#define CALL_FN(fn) do { DWORD __t = 0; __t = (DWORD)fn(); SetTagBit("__CallTrace_" #fn, __t); } while(0)
The wrapper consumes one bit tag per call site. Cross Reference then surfaces the __CallTrace_* tag, which engineers can grep back to its declaring script using the standard tag cross-reference lookup.
V8.1 Native Solution
WinCC V8.1 ships with a Project Search engine that scans the full project source text and updates the Cross Reference database. The engine is enabled by default; engineers invoke it through:
- Menu Tools → Project Search or the keyboard shortcut Ctrl+Shift+F.
- Enter the function name in the search field.
- Set scope to All project objects.
- Set object filter to CScripts + Pictures.
- Execute the search.
Project Search returns every match with line, column, file, and containing function or picture. The same index feeds the V8.1 Cross Reference GUI: when you select a project or standard CScript function and switch to the Usage tab, the pane now lists call sites inside other CScripts and inside picture events.
Configuration parameters
| Parameter | Default | Recommended | Notes |
|---|---|---|---|
| Project Search index update | Auto on save | Auto | Manual rebuild via Project → Rebuild search index after batch refactors. |
| Search scope | Active project | Active project | Cross-project search requires referenced project load. |
| CScript filter | Off | On | Disable only when scoping to PDL files. |
| Case sensitivity | Off | On for code search | Function names are case-sensitive in CScript. |
| Regex mode | Off | On for renames | Use \bPF_ prefix anchor to scope refactors. |
| Result count limit | 1000 | 5000 | Increase for large projects with >1000 functions. |
Configuring the Cross Reference Tool
Open the tool from Tools → Cross Reference. The dialog has two panes:
- Object tree (left): hierarchy of tags, pictures, CScript standard functions, CScript project functions, and library objects.
- Usage pane (right): filtered list of consuming objects with file path, line, and column.
Object-class filters are independent. Enable a filter to widen the search; disable a filter to narrow it. The V8.1 GUI adds a fifth filter named CScript calls which is the toggle that exposes function-to-function call sites. In V7.5 SP2 the toggle is absent.
State machine for index rebuild
V7.5 to V8.1 Migration Considerations
WinCC V8.1 is a forward-compatible drop-in upgrade for V7.5 SP2 projects. Migration steps:
- Take a complete project backup using the WinCC Project Duplicator.
- Open the V7.5 SP2 project in the V8.1 engineering station.
- Run Project → Migrate — the tool converts the project database and rebuilds the CScript compiler cache.
- Compile the project end-to-end. Resolve any V8.1 deprecation warnings (obsolete CScript APIs are removed).
- Open the Project Search index and verify that the project function count matches the migration report.
- Re-run the Cross Reference check from the verification procedure above; the result pane must now contain at least two entries per called function.
Comparison Matrix — WinCC Versions
| Capability | V7.5 SP2 | V8.0 | V8.1 |
|---|---|---|---|
| Tag cross-reference | Yes | Yes | Yes |
| Picture cross-reference | Yes | Yes | Yes |
| Function cross-reference (picture → function) | No | Partial | Yes |
| Function cross-reference (function → function) | No | Partial | Yes (via Project Search) |
| Project-wide text search | External (grep) | Limited | Built-in Project Search |
| CScript API deprecations | None | Warnings | Removals |
| TIA Portal cross-reference parity | Standalone only | Standalone only | Standalone + TIA V18 import |
Cross Reference Inside TIA Portal
TIA Portal V18 and later expose an equivalent Cross-references editor under Project tree → Common data → Cross-references. The TIA editor filters by criteria such as object type, address area, and access mode. For WinCC Unified panels the cross-reference information mirrors the TIA Portal editor rather than the legacy WinCC Explorer dialog. See the TIA Portal V21 cross-references documentation for the unified-panel workflow, including filter combinations and offline/online index behavior.
Troubleshooting Matrix
| Symptom | Likely Cause | Resolution |
|---|---|---|
| Cross Reference returns no usage for project function called from another project function | V7.5 SP2 indexer does not tokenize CScript function calls | Use Workaround A/B/C or migrate to V8.1 |
| Cross Reference returns no usage for standard function called from picture OnClick | V7.5 SP2 event-handler indexer gap | Use Workaround A or migrate to V8.1 |
| Cross Reference returns stale usage after rename | Stale index | Run Project → Rebuild cross-reference index and recompile |
| Tag references inside CScripts are missing | Standard header APDIALOG.h not included |
Add #include "APDIALOG.h" at top of CScript source |
| Project Search returns no results in V8.1 | Search index not built | Run Tools → Rebuild search index |
| Cross Reference pane empty after migration | Index migration step skipped | Compile full project, then rebuild index |
| Project Search regex returns unexpected matches | Regex mode toggled | Disable regex or anchor pattern with \b
|
| Standard functions missing from object tree | CScript library not loaded | Verify @PROJECT\library\*.dll references and recompile |
Field-Proven Validation Checklist
-
Standard header
APDIALOG.hpresent in every CScript that accesses tags. - Project compiles end-to-end without CScript errors or warnings.
- Cross Reference tool opened from Tools menu (not shortcut).
- Correct object class filter enabled (Tags, Pictures, Project functions, Standard functions, CScript calls).
- V8.1 only: Project Search index status reported as Ready.
- Selected function shows at least one usage entry when called from a picture or another script.
- Migration report archived with the project backup.
- Wrapper-macro debug tags removed before production runtime build.
Commissioning Notes
During factory acceptance tests (FAT), engineers typically validate that every CScript function has at least one expected call site before locking the project for shipment. With V7.5 SP2 this validation must be done manually via grep or via the Workaround B spreadsheet. With V8.1 the validation can be automated: open the Cross Reference GUI on every function in turn and export the usage tab to CSV. A function whose usage CSV is empty is a candidate for dead-code removal.
For large projects with more than 500 CScript functions, automate the validation with a WinCC V8.1 ODK script that iterates over the Cross Reference database and writes a markdown report at the project root. The ODK interface exposes IRuntimeProject::GetCrossReferences for read-only enumeration.
Safety Considerations
CScript function-call tracing is a design-time feature. Do not enable wrappers such as Workaround C on production panels. Tag writes triggered by wrappers can pollute the tag logging database, fire archive events, and in safety-relevant contexts, trigger unexpected acknowledgements on alarm lines. Remove all wrapper macros before generating the runtime file and re-run the verification procedure to confirm the index is still functional.
FAQ
Why does WinCC V7.5 SP2 Cross Reference not list CScript function calls?
The V7.5 SP2 indexer emits tokens only for tag accesses and picture references that survive the APDIALOG.h macro layer. It does not emit tokens for CScript FunctionCall opcodes, so function-to-function and event-handler-to-function calls are not recorded. The V8.1 text-based Project Search engine closes this gap.
How do I enable CScript call indexing in WinCC V8.1?
Open Tools → Project Search, ensure the index status is Ready, then open Tools → Cross Reference. Tick the new CScript calls filter in the object tree. The right pane now lists every script and picture that invokes the selected function.
What is the standard header required for tag cross-referencing in CScripts?
Include #include "APDIALOG.h" at the top of every CScript source file. Without it, tag references are not indexed and the Cross Reference pane shows zero usage for tags even when the script is otherwise correct.
Can I migrate a V7.5 SP2 project to V8.1 without rewriting the CScripts?
Yes. The migration tool converts the project database and rebuilds the CScript compiler cache. Project functions recompile without source changes unless they use APIs that V8.1 has removed. Review the V8.1 release notes for the removal list before migrating safety-relevant projects.
How does TIA Portal cross-reference differ from WinCC Explorer Cross Reference?
TIA Portal V18 and later expose a Cross-references editor under Project tree → Common data → Cross-references that filters by object type, address area, and access mode. For WinCC Unified panels the editor mirrors the TIA Portal workflow; for legacy WinCC Comfort and Advanced panels the WinCC Explorer dialog remains the canonical tool.
How do I rebuild the Cross Reference index after a bulk rename?
Open Project → Rebuild cross-reference index (or Tools → Rebuild search index on V8.1) and wait for the status indicator to return to Ready. Bulk renames through the script editor automatically trigger the rebuild; external renames via the file system do not, and require the manual rebuild step.