0

I'll be very pleased if you help.

My IDE is VS2010.

I'm using boost 1.47.0, especially boost::asio.

After some days of developing I decided to add log4cxx.

log4cxx needs to change calling convention to __stdcall

I surprisingly got lots of compiling error. They are ~ 70 errors.

I've googled a bit and found these:

#define BOOST_BIND_ENABLE_STDCALL 
#define BOOST_MEM_FN_ENABLE_STDCALL

It helps. Now there are just ~10 errors. Here there are:

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'

How can I solve them? Any little ideas or hints?

nix
  • 464
  • 1
  • 5
  • 13
  • please post the code you are attempting to compile – Sam Miller Nov 02 '11 at 14:31
  • @SamMiller I have too much code to post it. And, as you can see, I can't know where in my code those errors are. – nix Nov 02 '11 at 15:34
  • welcome to debugging! It will help us help you if you can boil the problem down to a [short, self contained, correct](http://sscce.org/) example. – Sam Miller Nov 02 '11 at 16:48

2 Answers2

1

You also need

  • #define BOOST_USE_WINDOWS_H
  • and possibly /Gz (__stdcall)
Venkat Peri
  • 1,744
  • 3
  • 16
  • 20
  • Good find, for me it was connected since I put `/Gz` from your suggestion which revealed incompatibility with `/clr:pure` where I then realized I changed to `/clr` in my `Release` configuration but didn't do the same for my `Debug` version. – jxramos Apr 28 '16 at 20:37
0

If your code looks something like:

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

using namespace log4cxx;
using namespace log4cxx::helpers;

int main()
{
//stuff
}

and you compile with -llog4cxx then you should be fine.

Philip Langford
  • 106
  • 1
  • 7