common: compile libstring-utils as C++
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 3 Sep 2021 21:31:29 +0000 (17:31 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 17 Nov 2021 23:39:09 +0000 (18:39 -0500)
commit6e53c52d3bf42bac72d7437684657ac442499616
tree20ce06552e80b620e7ca011ef4ae9e6a01f6eeb8
parent4bd69c5f1161cd065f487da0f4c1aa03a73c47e4
common: compile libstring-utils as C++

The code of string-utils.cpp is compiled as C++, but the functions are
still exported as C symbols for the moment (until all users are
converted to C++).

The only thing of interest here is this error:

      CXX      string-utils.lo
    /home/simark/src/lttng-tools/src/common/string-utils/string-utils.cpp: In function ‘star_glob_pattern_type_flags strutils_test_glob_pattern(const char*)’:
    /home/simark/src/lttng-tools/src/common/string-utils/string-utils.cpp:89:37: error: invalid conversion from ‘int’ to ‘star_glob_pattern_type_flags’ [-fpermissive]
       89 |                                 ret |= STAR_GLOB_PATTERN_TYPE_FLAG_END_ONLY;
          |                                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |                                     |
          |                                     int

In C++, you can't freely use bitwise operator on enumerators.  I added
an operator|= free function to handle it, which converts to the
underlying type and back.  If we have many of these enums used as flags,
we could think of adding a class for that, like enum_flags in GDB:

https://gitlab.com/gnutools/binutils-gdb/-/blob/7a6cb96b710257a4f5bc7e85cc103b6bf8dfc25c/gdbsupport/enum-flags.h

Change-Id: I64b458a6f6c1e5a131525826a116607eef824aaa
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/string-utils/Makefile.am
src/common/string-utils/string-utils.c [deleted file]
src/common/string-utils/string-utils.cpp [new file with mode: 0644]
This page took 0.027225 seconds and 4 git commands to generate.