background image
<< Simulating Functions with Varying Parameters | Simulating Functions with char Parameters >>
<< Simulating Functions with Varying Parameters | Simulating Functions with char Parameters >>

To work around this problem

Test RealTime - User Guide
Functions using
const
parameters sometimes produce compilation errors when
stubbed with Test RealTime.
This is because the preprocessor generates variables that are used for testing calls to
the STUBs. These variables have the same type as the parameter to the function being
stubbed:
const int
. These
const
variables cannot be modified, causing the compilation
errors.
To work around this problem, you can to indicate that type modifiers for a STUB
parameter should be used in the function definition, but not in the declaration of the
variables used to control the STUBs.
To do this, add an @ character as a prefix to the the type modifier. If your function
takes a
const
pointer, then you don't need the @ prefix:
This technique can be used with any type modifier.
Example
Consider the following function:
extern int ConstParam(const int param);
To stub the function, you would normally write the following lines in the .ptu test
script. These will produce compilation error messages:
DEFINE STUB Example
#int ConstParam(const int _in param);
END DEFINE
Instead, use the following syntax to define the stub:
DEFINE STUB Example
#int ConstParam(@const int _in param);
END DEFINE
If your function takes a
const
pointer:
DEFINE STUB Example
#int ConstParam(const int _in *param);
END DEFINE
Simulating Functions with void* Parameters
When stubbing a function that takes void* type parameters, the Source Code Parser
generates incomplete code that might not compile.
When you are stubbing functions that take void* parameters, you must check and
edit the .ptu test script accordingly.
Example
Consider the following test script generated by the C Source Code Parser:
DEFINE STUB fct_sim_c
#int fct_sim(double _in c, void _inout d);
150