Pulse-Eight/libcec — Issue #24: Compilation failure of PLATFORM::CCondition template class with XCode 4.2.1
Author: Dadeos
Created: 2012-02-18 20:20:01+00:00
State: open

Attempting to compile 960f33c651b2dd1e6331dafe5b21705c11cee1a2 on Mac OS X using the LLVM compiler that is part of XCode 4.2.1 yields the following errors:

Making all in src/lib
/bin/sh ../../libtool --tag=CXX --mode=compile g++ -DPACKAGE_NAME=\"libcec\" -DPACKAGE_TARNAME=\"libcec\" -DPACKAGE_VERSION=\"1:4:0\" -DPACKAGE_STRING=\"libcec\ 1:4:0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"libcec\" -DVERSION=\"1:4:0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -I/Users/peter/MythTV/libcec/include -fPIC -Wall -Wextra -Wno-missing-field-initializers -g -O2 -MT libcec_la-CECProcessor.lo -MD -MP -MF .deps/libcec_la-CECProcessor.Tpo -c -o libcec_la-CECProcessor.lo `test -f 'CECProcessor.cpp' || echo './'`CECProcessor.cpp
libtool: compile: g++ -DPACKAGE_NAME=\"libcec\" -DPACKAGE_TARNAME=\"libcec\" -DPACKAGE_VERSION=\"1:4:0\" "-DPACKAGE_STRING=\"libcec 1:4:0\"" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"libcec\" -DVERSION=\"1:4:0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -I/Users/peter/MythTV/libcec/include -fPIC -Wall -Wextra -Wno-missing-field-initializers -g -O2 -MT libcec_la-CECProcessor.lo -MD -MP -MF .deps/libcec_la-CECProcessor.Tpo -c CECProcessor.cpp -fno-common -DPIC -o .libs/libcec_la-CECProcessor.o
In file included from platform/threads/threads.h:34,
from CECProcessor.h:36,
from CECProcessor.cpp:33:
platform/threads/mutex.h: In instantiation of 'PLATFORM::CCondition':
platform/threads/mutex.h:345: instantiated from here
platform/threads/mutex.h:248: error: forming reference to reference type 'volatile bool&'
platform/threads/mutex.h:255: error: forming reference to reference type 'volatile bool&'
platform/threads/mutex.h: In member function 'bool PLATFORM::CEvent::Wait()':
platform/threads/mutex.h:306: error: 'class PLATFORM::CCondition' has no member named 'Wait'
platform/threads/mutex.h: In member function 'bool PLATFORM::CEvent::Wait(uint32_t)':
platform/threads/mutex.h:317: error: 'class PLATFORM::CCondition' has no member named 'Wait'
In file included from CECProcessor.h:36,
from CECProcessor.cpp:33:
platform/threads/mutex.h: At global scope:
platform/threads/mutex.h: In instantiation of 'PLATFORM::CCondition':
platform/threads/threads.h:139: instantiated from here
platform/threads/mutex.h:248: error: forming reference to reference type 'bool&'
platform/threads/mutex.h:255: error: forming reference to reference type 'bool&'
platform/threads/threads.h: In member function 'virtual bool PLATFORM::CThread::CreateThread(bool)':
platform/threads/threads.h:99: error: 'class PLATFORM::CCondition' has no member named 'Wait'
platform/threads/threads.h: In member function 'virtual bool PLATFORM::CThread::Sleep(uint32_t)':
platform/threads/threads.h:127: error: 'class PLATFORM::CCondition' has no member named 'Wait'
In file included from adapter/AdapterCommunication.h:34,
from CECProcessor.h:38,
from CECProcessor.cpp:33:
adapter/../platform/util/StdString.h: In function 'wchar_t* StdCodeCvt(wchar_t*, int, const char*, int, const std::locale&)':
adapter/../platform/util/StdString.h:868: warning: missing braces around initializer for 'char [128]'
adapter/../platform/util/StdString.h: In function 'char* StdCodeCvt(char*, int, const wchar_t*, int, const std::locale&)':
adapter/../platform/util/StdString.h:911: warning: missing braces around initializer for 'char [128]'
make[1]: *** [libcec_la-CECProcessor.lo] Error 1
make: *** [all-recursive] Error 1

These issues are caused by the `_Predicate` template type of the `PLATFORM::CCondition` class being defined as a reference to the intended type and the `PLATFORM::CCondition::Wait()` functions being defined as taking references to the `_Predicate` template type, resulting in a double-reference.

If the declaration of the `PLATFORM::CThread::m_threadCondition` member variable is changed from:

CCondition

to:

CCondition

then these errors are avoided.

There are also number of other uses of the `PLATFORM::CCondition` class that would require similar treatment.