Post Instrumentation Script to #undef a Recursive Macro

Issue:

Including a header file that uses the struct sigaction results in the following compilation error:

error: union sigaction::<anonymous> has no member names __sigaction_handler
 

Solution:

The problem is a recursive macro in signal.h:

# define sa_handler __sigaction_handler.sa_handler
 

When setting the expanded header to collapse system headers or collapse non-search directory headers, the effect is that the header file is expanded twice and the harness code as a result then references sigaction_handler.
 

In the VectorCAST unit test, the right place to fix this error is by adding a #undef in driver prefix user code. In the VectorCAST QA, however, it will require that a post-instrument script is used to insert the #undef in the instrumented source file. Here is an example script:
 

sed -i -e '/#include .*signal.h"/s/$/\
#undef sa_handler/' $1

 



Article ID: 1495
Last updated: 2019-11-04
Revision: 4
VectorCAST -> Troubleshooting -> Post Instrumentation Script to #undef a Recursive Macro
https://kb.vector.com/entry/1495/