Some urcu header files cause build failures when included in C++
programs. Add a test file that includes all exported headers (except
those that are marked as deprecated) and build that test file as a C and
C++ program, with and without _LGPL_SOURCE defined (to test both the
static and non-static implementations). This helps ensure that the code
in these headers works as both languages. This alone does not ensure
full coverage, there may be code in unused macros that would need
fixing. But by including the "static" headers, this already finds a few
issues.
The test doesn't run anything, its purpose is only to verify that things
build.
This catches the following build failures:
- clang++ doesn't know the __transparent_union__ attribute, place some
pragmas to ignore this warning around where __transparent_union__ is
used.
- CDS_WFS_WOULDBLOCK and CDS_WFS_END are cast to a void*. This doesn't
work in C++ when assigning to a field them to typed pointer. Fix
them by casting to the appropriate type.
- The transparent union trick doesn't work in C++:
CXX test_build_cxx.o
In file included from /home/simark/src/urcu/include/urcu/wfstack.h:116,
from /home/simark/src/urcu/include/urcu/cds.h:35,
from /home/simark/src/urcu/tests/unit/test_build_cxx.cpp:34:
/home/simark/src/urcu/include/urcu/static/wfstack.h: In function ‘cds_wfs_node* _cds_wfs_pop_with_state_blocking(cds_wfs_stack*, int*)’:
/home/simark/src/urcu/include/urcu/static/wfstack.h:350:54: error: could not convert ‘s’ from ‘cds_wfs_stack*’ to ‘cds_wfs_stack_ptr_t’
350 | retnode = ___cds_wfs_pop_with_state_blocking(s, state);
| ^
| |
| cds_wfs_stack*
A C++ user can fall back to instantiating a cds_wfs_stack_ptr_t
explicitly, assigning the right field, and passing the
cds_wfs_stack_ptr_t to the function. Fix a few instances in the
static headers.
A follow up commit will introduce C++ API wrappers based on
function overloading to provide a C++ API similar to the C API.
Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I30adc8df69414a0a019c5ec081f64cfac64843f5