1

在 Visual Studio 2012 中构建,APR 1.4.8 APR-UTIL 1.5.2 Log4cxx 0.10

运行配置和配置-apr

然后在VS中打开并得到111 C2252错误(它来自宏):

//
//   pointer and list definition macros when building DLL using VC
//
#if defined(_MSC_VER) && !defined(LOG4CXX_STATIC) && defined(LOG4CXX)
#define LOG4CXX_PTR_DEF(T) \
template class LOG4CXX_EXPORT log4cxx::helpers::ObjectPtrT<T>; \
typedef log4cxx::helpers::ObjectPtrT<T> T##Ptr
#define LOG4CXX_LIST_DEF(N, T) \
template class LOG4CXX_EXPORT std::allocator<T>; \
template class LOG4CXX_EXPORT std::vector<T>; \
typedef std::vector<T> N

有什么想法我应该怎么做?

4

3 回答 3

2

看起来删除以“模板”开头的 2 行可以解决这个问题。

删除这个:

template class LOG4CXX_EXPORT std::allocator<T>; \
template class LOG4CXX_EXPORT std::vector<T>; \
于 2013-08-21T21:45:42.757 回答
1

看看这个错误报告:LOGCXX-366

解决方法的摘要:

编辑/src/main/cpp/stringhelper.cpp,添加:

#include <iterator>

编辑/src/main/include/log4cxx/log4cxx.hw,删除以下几行:

template class LOG4CXX_EXPORT std::allocator<T>; \
template class LOG4CXX_EXPORT std::vector<T>; \

extern template class LOG4CXX_EXPORT std::allocator<T>; \
extern template class LOG4CXX_EXPORT std::vector<T>; \
于 2014-02-04T10:10:44.343 回答
0

此错误是由于 VC++ 中的一个可以解决的错误造成的。

  1. 将所有宏移到它们所在的类之外(上方)。LOG4CXX_LIST_DEF 宏用于定义类。在错误 C2252 中报告的所有宏都需要移出任何类。这也可能包括宏中使用的移动定义。
  2. 接下来,将所有 LoggingEvent::KeySet 更改为 KeySet(这不再嵌套在父类中)

有关如何在 Windows 操作系统上的 Visual Studio 2013 中编译 Log4cxx 的完整答案,请参阅我的完整答案:https ://stackoverflow.com/a/36737721/3637582

于 2016-04-20T08:29:49.190 回答