Call Function Only When the Unit is Part of VectorCAST Environment

Question:
How do I call a function only when the unit is part of a VectorCAST environment?
Answer:

A convenient #define is part of VectorCAST.  When VectorCAST/C++ preprocesses a unit under test, it defines VECTORCAST. Thus, if you want to run some code in your source file only when it is used in a VectorCAST environment, you can add the following to your source code:
 

#ifdef VECTORCAST
... code here ...
#endif
 

VECTORCAST will be defined when the unit is preprocessed during environment build.
 



Article ID: 1457
Last updated: 2019-10-24
Revision: 2
VectorCAST -> C++ Unit Testing -> Call Function Only When the Unit is Part of VectorCAST Environment
https://kb.vector.com/entry/1457/