I wrote:
The first issues is the order of the include files basically anywhere <avl.h> is included it is picking up /usr/include/sys/avl.h instead of the openldap avl.h library. You can pretty much just grep for <avl.h> or "avl.h" and find all the places it conflicts.
There's a Sun bugid out there somewhere about avl.h spamming the user namespace.
BugID: 6419029 http://bugs.opensolaris.org/view_bug.do?bug_id=6419029
Fix should be in patch 118855-36 but I haven't verified that yet.
-Ben