BwTree
BwTree copied to clipboard
cannot build with clang++
Trying to compile BwTree with clang++, I get these warnings that don't make a lot of sense to me:
In file included from ./test/main.cpp:2:
In file included from ./test/test_suite.h:20:
./test/../src/bwtree.h:9394:5: error: 'GarbageNode' is a private member of
'wangziqi2013::bwtree::BwTreeBase'
GarbageNode *garbage_node_p = \
^
./test/../src/bwtree.h:210:9: note: implicitly declared private here
class GarbageNode {
^
./test/../src/bwtree.h:9395:11: error: 'GarbageNode' is a private member of
'wangziqi2013::bwtree::BwTreeBase'
new GarbageNode{GetGlobalEpoch(), (void *)(node_p)};
^
./test/../src/bwtree.h:210:9: note: implicitly declared private here
class GarbageNode {
those declarations look public to me, and trying to mimic your class structure with a small test case did not cause any problems. I clearly oversimplified...
class Foo {
class Bar {
public:
Bar(int a, int b) {}
};
void do_stuff() {
Bar *bar_p = new Bar{5, 10};
}
};
@roblatham00 The problem with Clang is that class GarbageNode is private to all classes that is not a friend of class BwTreeBase, and in the meantime it is accessible by classes defined in class BwTreeBase. This is just like a class's member functions could access its private members, but other non-friend classes could not.
Explicitly declaring class GarbageNode in class BwTreeBase as public could solve the problem.
I had the same issue. Not only GarbageNode
but also GC_NODE_COUNT_THREADHOLD
and gc_id
led to the same errors (... is a private member of 'wangziqi2013::bwtree::BwTreeBase
).
A possible quick-and-dirty fix (git diff
output):
diff --git a/src/bwtree.h b/src/bwtree.h
index 781a992..3988683 100644
--- a/src/bwtree.h
+++ b/src/bwtree.h
@@ -197,6 +197,7 @@ class BwTreeBase {
// This is the mask we used for address alignment (AND with this)
static constexpr size_t CACHE_LINE_MASK = ~(CACHE_LINE_SIZE - 1);
+ public:
// We invoke the GC procedure after this has been reached
static constexpr size_t GC_NODE_COUNT_THREADHOLD = 1024;
@@ -232,6 +233,7 @@ class BwTreeBase {
{}
};
+ private:
/*
* class GCMetaData - Metadata for performing GC on per-thread basis
*/
@@ -305,13 +307,14 @@ class BwTreeBase {
"class PaddedGCMetadata size does"
" not conform to the alignment!");
- private:
+ public:
// This is used as the garbage collection ID, and is maintained in a per
// thread level
// This is initialized to -1 in order to distinguish between registered
// threads and unregistered threads
static thread_local int gc_id;
+ private:
// This is used to count the number of threads participating GC process
// We use this number to initialize GC data structure
static std::atomic<size_t> total_thread_num;