On 8/14/2025 9:44 AM, Stanislav Fomichev wrote:
Compiling ynl.c in a C++ code base requires invoking C compiler and
using extern "C" for the headers. To make it easier, we can add
small changes to the ynl.c file to make it palatable to the native
C++ compiler. The changes are:
- avoid using void* pointer arithmetic, use char* instead
- avoid implicit void* type casts, add c-style explicit casts
- avoid implicit int->enum type casts, add c-style explicit casts
- avoid anonymous structs (for type casts)
- namespacify cpp version, this should let us compile both ynl.c
as c and ynl.c as cpp in the same binary (YNL_CPP can be used
to enable/disable namespacing)
The changes seem ok to me. Obviously these violate several of the usual
kernel style guidelines.. But this is a library which has a lot more
reason to be compiled with C++.
Also add test_cpp rule to make sure ynl.c won't break C++ in the future.
Thanks. Is this run in some part of automation so we can catch issues
from future patches? Ah. I see it is run as part of the normal "all"
target. Ok.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>