abseil-cpp, absl in thirdparty redefinition error

I have encountered another problem and I am not sure if it will be helpful to you

  • protobuf version 3.26.1 (ver 2024-04)
  • Unreal Engine version 5.3
  • vs2022 community

Reason:
The function verify() defined in the absl/container/internal/btree. h and absl/container/internal/btree. container.h files conflicts with the verify(expr) macro defined in UE5.

Solution:
In the context of function definition, cancel the macro definition of UE.

This is the code that I have personally modified, and there may be other ways to modify it.

  1. Around line 1579 of the btree.h file, after modification:
#ifdef verify
#undef verify
#endif
  // Verifies the structure of the btree.
  void verify() const;
#ifndef verify
#define verify(expr)			UE_CHECK_IMPL(expr)  // copy from line 221 of /Engine/Source/Runtime/Core/Public/Misc/AssertionMacros.h
#endif
  1. Around line 2610 of the btree.h file, after modification:
#ifdef verify
#undef verify
#endif
template <typename P>
void btree<P>::verify() const {
  assert(root() != nullptr);
  assert(leftmost() != nullptr);
  assert(rightmost() != nullptr);
  assert(empty() || size() == internal_verify(root(), nullptr, nullptr));
  assert(leftmost() == (++const_iterator(root(), -1)).node_);
  assert(rightmost() == (--const_iterator(root(), root()->finish())).node_);
  assert(leftmost()->is_leaf());
  assert(rightmost()->is_leaf());
}
#ifndef verify
#define verify(expr)			UE_CHECK_IMPL(expr)  // copy from line 221 of /Engine/Source/Runtime/Core/Public/Misc/AssertionMacros.h
#endif
  1. Around line 225 of the btree_container.h file, after modification:
#ifdef verify
#undef verify
#endif
  void verify() const { tree_.verify(); }
#ifndef verify
#define verify(expr)			UE_CHECK_IMPL(expr)  // copy from line 221 of /Engine/Source/Runtime/Core/Public/Misc/AssertionMacros.h
#endif

Hope it’s helpful
Best wishes

4 Likes