IBM Support

How to stub macros in Rational Test RealTime

Technote (FAQ)


How do you stub macros in IBM Rational Test RealTime?


Macros cannot be stubbed. You can only stub C functions and C++ methods.


The macros that you stub needs to be converted to a C function or C++ method call .

Below is a sample on how to convert a C macro to a function call and stub it.

Example : You have the following macro defined in the file calc.h.

#define doAdd(x,y) (x + y)

Then it can be redefined to a C function call as below:

function call:

#ifndef doAdd
#define doAdd(x,y) (x + y)

Now in the DCL file you can write

#define doAdd(x,y) stubAdd(x,y)
extern int stubAdd(int x, int y);
#include "calc.h"
#include "calc.cpp"

Note: For code under test to be included, such that the new macro definition takes affect in the code, you need to modify the .STB file

STUB stubAdd : int stubAdd(int x, int y)
PRINT ("In stubAdd");
#return (x + y);

Attached is the sample snippet of the code.


All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Document information

More support for: Rational Test RealTime
Component Testing

Software version: 7.5, 8.0,,,

Operating system(s): AIX, HP-UX, Linux, Solaris, Windows

Reference #: 1622389

Modified date: 01 April 2013

Translate this page: