使用__stdcall和Boost 1.47.0编译错误log4cxx

时间:2011-11-02 12:35:27

标签: c++ visual-studio-2010 boost log4cxx stdcall

如果你帮忙,我会很高兴的。

我的IDE是VS2010。

我正在使用提升1.47.0 ,特别是boost :: asio。

经过几天的开发后,我决定添加log4cxx。

log4cxx 需要将调用约定更改为 __ stdcall

我出乎意料地得到了很多编译错误。它们有大约70个错误。

我用Google搜索了一下,发现了这些:

#define BOOST_BIND_ENABLE_STDCALL 
#define BOOST_MEM_FN_ENABLE_STDCALL

有帮助。现在只有大约10个错误。 这里有:

1>ClCompile:
1>  main.cpp
1>D:\Development\lib\boost_1_47_0\boost/detail/interlocked.hpp(61): error C2373: '_InterlockedCompareExchange' : redefinition; different type modifiers
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\intrin.h(214) : see declaration of '_InterlockedCompareExchange'
1>D:\Development\lib\boost_1_47_0\boost/detail/interlocked.hpp(62): error C2373: '_InterlockedExchange' : redefinition; different type modifiers
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\intrin.h(192) : see declaration of '_InterlockedExchange'
1>D:\Development\lib\boost_1_47_0\boost/detail/interlocked.hpp(63): error C2373: '_InterlockedExchangeAdd' : redefinition; different type modifiers
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\intrin.h(204) : see declaration of '_InterlockedExchangeAdd'
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/sp_counted_base_w32.hpp(92): error C2446: '==' : no conversion from 'long' to 'long (__stdcall *)(volatile long *,long,long)'
1>          Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/sp_counted_base_w32.hpp(92): error C2040: '==' : 'long (__stdcall *)(volatile long *,long,long)' differs in levels of indirection from 'long'
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/sp_counted_base_w32.hpp(92): error C3861: '_InterlockedCompareExchange': identifier not found
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/spinlock_w32.hpp(62): error C3861: '_InterlockedExchange': identifier not found
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/spinlock_w32.hpp(62): error C2440: 'initializing' : cannot convert from 'long (__stdcall *)(volatile long *,long)' to 'long'
1>          There is no context in which this conversion is possible
1>D:\Development\lib\boost_1_47_0\boost/asio/detail/impl/signal_set_service.ipp(74): error C2664: 'signal' : cannot convert parameter 2 from 'void (__stdcall *)(int)' to 'void (__cdecl *)(int)'
1>          None of the functions with this name in scope match the target type
1>D:\Development\lib\boost_1_47_0\boost/asio/detail/impl/signal_set_service.ipp(246): error C2664: 'signal' : cannot convert parameter 2 from 'void (__stdcall *)(int)' to 'void (__cdecl *)(int)'
1>          None of the functions with this name in scope match the target type
1>main.cpp(20): warning C4007: 'main' : must be '__cdecl'

我该如何解决? 有什么小想法或提示吗?

2 个答案:

答案 0 :(得分:1)

您还需要

  • #define BOOST_USE_WINDOWS_H
  • 和可能/ Gz(__stdcall)

答案 1 :(得分:0)

如果您的代码类似于:

#include "log4cxx/logger.h"
#include "log4cxx/basicconfigurator.h"
#include "log4cxx/helpers/exception.h"

using namespace log4cxx;
using namespace log4cxx::helpers;

int main()
{
//stuff
}

然后用-llog4cxx编译,那么你应该没问题。