summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2019-06-03 15:41:05 +0200
committerDavid Lamparter <equinox@diac24.net>2019-06-11 18:45:38 +0200
commita7f20d4328092b382c26c6d738e575c1ead9dc91 (patch)
tree32169265160a11e069dc58c9d08bae1d9c8593a5 /tests/lib
parentMerge pull request #4482 from opensourcerouting/warnings-20190606 (diff)
downloadfrr-a7f20d4328092b382c26c6d738e575c1ead9dc91.tar.xz
frr-a7f20d4328092b382c26c6d738e575c1ead9dc91.zip
lib: const-unaware container_of for C++
This version of container_of() should work on C++, by ditching the unavailable builtins (at the cost of no longer checking for "const" violations.) Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/cxxcompat.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/lib/cxxcompat.c b/tests/lib/cxxcompat.c
index 48fa0ec8a..6624de738 100644
--- a/tests/lib/cxxcompat.c
+++ b/tests/lib/cxxcompat.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#define test__cplusplus
+
#include "lib/zebra.h"
#include "lib/agg_table.h"
@@ -107,6 +109,17 @@
#include "lib/zassert.h"
#include "lib/zclient.h"
+PREDECL_RBTREE_UNIQ(footree)
+struct foo {
+ int dummy;
+ struct footree_item item;
+};
+static int foocmp(const struct foo *a, const struct foo *b)
+{
+ return memcmp(&a->dummy, &b->dummy, sizeof(a->dummy));
+}
+DECLARE_RBTREE_UNIQ(footree, struct foo, item, foocmp)
+
int main(int argc, char **argv)
{
return 0;