Opened 12 years ago

Closed 5 years ago

#5431 closed Bugs (fixed)

compile error in Windows CE 6.0(interlocked)

Reported by: Akira Takahashi <faithandbrave@…> Owned by: James E. King, III
Milestone: Boost 1.66.0 Component: winapi
Version: Boost 1.55.0 Severity: Problem
Keywords: wince interlocked Cc: viboes

Description

boost/detail/interlocked.hpp is compile error in Windows CE platform.

error C2733 : second C linkage of overloaded function 'InterlockedXXX' not allowed

I correct follow change:

before

#elif defined(_WIN32_WCE)

// under Windows CE we still have old-style Interlocked* functions

extern "C" long __cdecl InterlockedIncrement( long* );
extern "C" long __cdecl InterlockedDecrement( long* );
extern "C" long __cdecl InterlockedCompareExchange( long*, long, long );
extern "C" long __cdecl InterlockedExchange( long*, long );
extern "C" long __cdecl InterlockedExchangeAdd( long*, long );

# define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement
# define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
# define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange
# define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd

after:

# define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement
# define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
# define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange
# define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd

Change History (26)

comment:1 by Akira Takahashi <faithandbrave@…>, 12 years ago

sorry, after code is follow:

#elif defined(_WIN32_WCE)

# define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement
# define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
# define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange
# define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd

comment:2 by viboes, 11 years ago

Cc: viboes added

Which boost library is including the detail/interlocked.hpp file?

Could you send the declarations of the InterlockedXXX functions you have on your WindowsCE platform and the version?

comment:3 by faithandbrave@…, 11 years ago

detail/interlocked.hpp used by Boost.Thread. include place is boost/thread/win32/interlocked_read.hpp.

WindowsCE Version $(CEVER) is defined as 0x600.

_WIN32_WCE=$(CEVER)

InterlockedXXX function declaration is follow:

winbase.h

#ifdef __cplusplus
extern "C" {
#endif

...

#ifdef MIPS_R4000 /* or above */
...
#elif defined(_X86_)
...
#else // not _X86_

LONG
WINAPI
InterlockedIncrement(
    LONG volatile *lpAddend
    );


LONG
WINAPI
InterlockedDecrement(
    LONG volatile *lpAddend
    );


LONG
WINAPI
InterlockedExchange(
    LONG volatile *Target,
    LONG Value
    );

LONG
WINAPI
InterlockedCompareExchange(
    LONG volatile *Target,
    LONG Exchange,
    LONG Comperand
    );

LONG
WINAPI
InterlockedExchangeAdd(
    LONG volatile *lpAddend,
    LONG Value
    );

#define InterlockedTestExchange(Target, oldValue, newValue) \
    InterlockedCompareExchange((Target), (newValue), (oldValue))

#endif

...
#ifdef __cplusplus
}
#endif

comment:4 by viboes, 11 years ago

Keywords: CE interlocked added

comment:5 by viboes, 11 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

comment:6 by anonymous, 11 years ago

Keywords: wince added; CE removed

comment:7 by viboes, 10 years ago

Could changing the declarations to

extern "C" long __cdecl InterlockedIncrement( long volatile * );
extern "C" long __cdecl InterlockedDecrement( long volatile * );
extern "C" long __cdecl InterlockedCompareExchange( long volatile *, long, long );
extern "C" long __cdecl InterlockedExchange( long volatile *, long );
extern "C" long __cdecl InterlockedExchangeAdd( long volatile *, long );

solve also the issue?

comment:8 by Akira Takahashi <faithandbrave@…>, 10 years ago

I think that change is OK. But unfortunately, I have already left from the Windows CE platform. I can't test this change.

in reply to:  7 comment:9 by mboard182@…, 10 years ago

Replying to viboes:

Could changing the declarations to

extern "C" long __cdecl InterlockedIncrement( long volatile * );
extern "C" long __cdecl InterlockedDecrement( long volatile * );
extern "C" long __cdecl InterlockedCompareExchange( long volatile *, long, long );
extern "C" long __cdecl InterlockedExchange( long volatile *, long );
extern "C" long __cdecl InterlockedExchangeAdd( long volatile *, long );

solve also the issue?

Yes, this appears to solve the link error. Can you help me understand why??

AFAIK with 'extern "C"', the following have the same name (and indeed will not link for me on vc9.0/winCE6 arm)

void foo(int *i){...}
void foo(volatile int *i){...}

comment:10 by viboes, 10 years ago

Milestone: To Be DeterminedBoost 1.52.0

Committed in trunk revision 80042.

comment:11 by viboes, 10 years ago

Milestone: Boost 1.52.0To Be Determined

comment:12 by viboes, 10 years ago

last update rolledback as it make regression test fail. Committed in trunk revision [80067]. I will try making the modification only when _WIN32_WCE==0x600.

comment:13 by viboes, 10 years ago

Milestone: To Be DeterminedBoost 1.52.0

Committed in trunk revision [80127].

Last edited 10 years ago by viboes (previous) (diff)

comment:14 by viboes, 10 years ago

Resolution: fixed
Status: assignedclosed

Merged from trunk [80473].

comment:15 by Martin.problemboost.Maurer@…, 10 years ago

I got the same error under Windows Vista, Visual Studio Express 2008, using 64 bit compiler and intrin.h my in own program. Same situation with boost 1.51.0 and 1.53.0 Could be because the above bugfix seems to be activated only for Windows CE, but i have Vista not Windows CE. Any idea?

comment:16 by viboes, 10 years ago

Please, create a new ticket as even if your problem is related it is for a different platform. Could you tell me which macro characterize your platform? If you could provide a patch this would help a lot.

comment:17 by anonymous, 9 years ago

Similar error under Vista, VS2008, 64 bit compiler: https://svn.boost.org/trac/boost/ticket/8485

comment:18 by christian.vollmer@…, 8 years ago

I got the same problem with the same platform but for the current boost version of 1.55. However, commenting out the section that handled the special case for _WIN32_WCE >= 0x600 solved the issue. Now the code looks like this:

//#if _WIN32_WCE >= 0x600
//
//extern "C" long __cdecl _InterlockedIncrement( long volatile * );
//extern "C" long __cdecl _InterlockedDecrement( long volatile * );
//extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
//extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
//extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long );
//
//# define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement
//# define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement
//# define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
//# define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange
//# define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
//
//#else
// under Windows CE we still have old-style Interlocked* functions

//extern "C" long __cdecl InterlockedIncrement( long* );
//extern "C" long __cdecl InterlockedDecrement( long* );
//extern "C" long __cdecl InterlockedCompareExchange( long*, long, long );
//extern "C" long __cdecl InterlockedExchange( long*, long );
//extern "C" long __cdecl InterlockedExchangeAdd( long*, long );

# define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement
# define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange
# define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange
# define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd

//#endif

comment:19 by anonymous, 8 years ago

Resolution: fixed
Status: closedreopened

comment:20 by viboes, 8 years ago

Milestone: Boost 1.52.0To Be Determined
Version: Boost 1.46.1Boost 1.55.0

comment:21 by viboes, 8 years ago

Component: threadNone
Owner: changed from viboes to Peter Dimov
Status: reopenednew

Peter please, could you take a look at this issue?

comment:22 by Peter Dimov, 8 years ago

I don't have access to any Windows CE platform, so I'm not sure what I can contribute. I don't even understand what problem is being discussed here.

comment:23 by viboes, 8 years ago

Component: Nonewinapi

comment:24 by James E. King, III, 5 years ago

Milestone: To Be DeterminedBoost 1.66.0
Owner: changed from Peter Dimov to James E. King, III

comment:25 by James E. King, III, 5 years ago

comment:26 by Andrey Semashev, 5 years ago

Resolution: fixed
Status: newclosed

I've committed the fix in https://github.com/boostorg/winapi/commit/e5a59445bfe3f8f5f6077d1e7b4d5d91a02a10af. I'm not able to test the change and would appreciate if anyone here is able to try it.

Note: See TracTickets for help on using tickets.