locked
[HELP] Complieing Boost with vc2010 RRS feed

  • Question

  • I've seem to have a issue complieing boost_1_44..

    Any one have any suggestions into why this is happenning with the precomplied headers...

     

    c:\program files\boost\boost_1_45_0\boost\thread\win32\basic_timed_mutex.hpp(149): error C2679: binary '+' : no operator found which takes a right-hand operand of type 'const bool' (or there is no acceptable conversion)
    
    1>     C:\Program Files\Boost\boost_1_45_0\boost/date_time/posix_time/date_duration_operators.hpp(31): could be 'boost::posix_time::ptime boost::posix_time::operator +(const boost::posix_time::ptime &,const boost::gregorian::months &)' [found using argument-dependent lookup]
    
    1>     C:\Program Files\Boost\boost_1_45_0\boost/date_time/date_duration_types.hpp(132): or    'boost::gregorian::date boost::date_time::months_duration<base_config>::operator +(const boost::gregorian::date &,const boost::date_time::months_duration<base_config> &)' [found using argument-dependent lookup]
    
    1>     with
    
    1>     [
    
    1>       base_config=boost::gregorian::greg_durations_config
    
    1>     ]
    
    1>     C:\Program Files\Boost\boost_1_45_0\boost/date_time/posix_time/date_duration_operators.hpp(75): or    'boost::posix_time::ptime boost::posix_time::operator +(const boost::posix_time::ptime &,const boost::gregorian::years &)' [found using argument-dependent lookup]
    
    1>     C:\Program Files\Boost\boost_1_45_0\boost/date_time/date_duration_types.hpp(244): or    'boost::gregorian::date boost::date_time::years_duration<base_config>::operator +(const boost::gregorian::date &,const boost::date_time::years_duration<base_config> &)' [found using argument-dependent lookup]
    
    1>     with
    
    1>     [
    
    1>       base_config=boost::gregorian::greg_durations_config
    
    1>     ]
    
    1>     C:\Program Files\Boost\boost_1_45_0\boost/date_time/time.hpp(139): or    'boost::posix_time::ptime boost::date_time::base_time<T,time_system>::operator +(const boost::gregorian::date_duration &) const'
    
    1>     with
    
    1>     [
    
    1>       T=boost::posix_time::ptime,
    
    1>       time_system=boost::posix_time::posix_time_system
    
    1>     ]
    
    1>     C:\Program Files\Boost\boost_1_45_0\boost/date_time/time.hpp(159): or    'boost::posix_time::ptime boost::date_time::base_time<T,time_system>::operator +(const boost::posix_time::time_duration &) const'
    
    1>     with
    
    1>     [
    
    1>       T=boost::posix_time::ptime,
    
    1>       time_system=boost::posix_time::posix_time_system
    
    1>     ]
    
    1>     while trying to match the argument list '(boost::system_time, const bool)'
    
    1>     C:\Program Files\Boost\boost_1_45_0\boost/thread/locks.hpp(427) : see reference to function template instantiation 'bool boost::detail::basic_timed_mutex::timed_lock<TimeDuration>(const Duration &)' being compiled
    
    1>     with
    
    1>     [
    
    1>       TimeDuration=bool,
    
    1>       Duration=bool
    
    1>     ]
    
    1>     C:\Program Files\Boost\boost_1_45_0\boost/thread/locks.hpp(307) : see reference to function template instantiation 'bool boost::unique_lock<Mutex>::timed_lock<TimeDuration>(const TimeDuration &)' being compiled
    
    1>     with
    
    1>     [
    
    1>       Mutex=boost::mutex,
    
    1>       TimeDuration=bool
    
    1>     ]
    
    1>     ..\Common\logging.cpp(7) : see reference to function template instantiation 'boost::unique_lock<Mutex>::unique_lock<bool>(Mutex &,const TimeDuration &)' being compiled
    
    1>     with
    
    1>     [
    
    1>       Mutex=boost::mutex,
    
    1>       TimeDuration=bool
    
    1>     ]

    Thankyou for your help....

     

     

    my source code looks like this..

    #include <boost/thread.hpp>
    
    #include <boost/bind.hpp>
    
    #include <boost/thread/condition.hpp>
    
    
    
    class ReadWriteMutex : boost::noncopyable
    
    {
    
    public:
    
        ReadWriteMutex() :
    
            m_readers(0),
    
            m_pendingWriters(0),
    
            m_currentWriter(false)
    
        {}
    
    
    
        class ScopedReadLock : boost::noncopyable
    
        {
    
        public:
    
            ScopedReadLock(ReadWriteMutex& rwLock) :
    
                m_rwLock(rwLock)
    
            {
    
                m_rwLock.acquireReadLock();
    
            }
    
    
    
            ~ScopedReadLock()
    
            {
    
                m_rwLock.releaseReadLock();
    
            }
    
    
    
        private:
    
            ReadWriteMutex& m_rwLock;
    
        };
    
    
    
        class ScopedWriteLock : boost::noncopyable
    
        {
    
        public:
    
            ScopedWriteLock(ReadWriteMutex& rwLock) :
    
                m_rwLock(rwLock)
    
            {
    
                m_rwLock.acquireWriteLock();
    
            }
    
    
    
            ~ScopedWriteLock()
    
            {
    
                m_rwLock.releaseWriteLock();
    
            }
    
    
    
        private:
    
            ReadWriteMutex& m_rwLock;
    
        };
    
    
    
        void acquireReadLock()
    
        {
    
            boost::mutex::scoped_lock lock(m_mutex);
    
    
    
            while(m_pendingWriters != 0 || m_currentWriter)
    
            {
    
                m_writerFinished.wait(lock);
    
            }
    
            ++m_readers;
    
        }
    
    
    
        void releaseReadLock()
    
        {
    
            boost::mutex::scoped_lock lock(m_mutex);
    
            --m_readers;
    
    
    
            if(m_readers == 0)
    
            {
    
                m_noReaders.notify_all();
    
            }
    
        }
    
    
    
        void acquireWriteLock()
    
        {
    
            boost::mutex::scoped_lock lock(m_mutex);
    
    
    
            ++m_pendingWriters;
    
    
    
            while(m_readers > 0)
    
            {
    
                m_noReaders.wait(lock);
    
            }
    
    
    
            while(m_currentWriter)
    
            {
    
                m_writerFinished.wait(lock);
    
            }
    
            --m_pendingWriters;
    
            m_currentWriter = true;
    
        }
    
    
    
        void releaseWriteLock()
    
        {        
    
            boost::mutex::scoped_lock lock(m_mutex);
    
            m_currentWriter = false;
    
            m_writerFinished.notify_all();
    
        }
    
    
    
    private:
    
        boost::mutex m_mutex;
    
    
    
        unsigned int m_readers;
    
        boost::condition m_noReaders;
    
    
    
        unsigned int m_pendingWriters;
    
        bool m_currentWriter;
    
        boost::condition m_writerFinished;
    
    };

     

    • Moved by lucy-liu Monday, February 7, 2011 9:50 AM it is not related to vc (From:Visual C++ General)
    Thursday, January 20, 2011 8:18 AM

All replies

  • FaceofDevil wrote:

    I've seem to have a issue complieing boost_1_44..

    1>     ..\Common\logging.cpp(7) : see reference to function template  instantiation
    'boost::unique_lock<Mutex>::unique_lock<bool>(Mutex &,const  TimeDuration &)' being compiled

    What does line 7 in logging.cpp look like? Why are you trying to pass  bool for TimeDuration parameter?


    Igor Tandetnik

    Thursday, January 20, 2011 3:07 PM
  • boost::mutex mConsole;
    
    void Log( LOG_TYPE flag, char *format, ... )
    {
    	boost::mutex::scoped_lock lConsole( mConsole, false );
    
    	va_list arglist;
    	va_start( arglist, format );
    
    	switch( flag )
    	{
    	case MSG_NONE:
    		SetConsoleColor( CC_WHITE );
    		printf( "[MSG]: " );
    		break;
    
    	case MSG_LOAD:
    		SetConsoleColor( CC_LIGHTMAGENTA );
    		printf( "[LOAD]: " );
    		break;
    
    	case MSG_STATUS:
    		SetConsoleColor( CC_LIGHTGREEN );
    		printf( "[STATUS]: " );
    		break;
    
    	case MSG_INFO:
    		SetConsoleColor( CC_GREEN );
    		printf( "[INFO]: " );
    		break;
    
    	case MSG_WARNING:
    		SetConsoleColor( CC_LIGHTMAGENTA );
    		printf( "[WARNING]: " );
    		break;
    
    	case MSG_ERROR:
    		SetConsoleColor( CC_LIGHTRED );
    		printf( "[ERROR]: " );
    		break;
    
    	case MSG_DEBUG:
    		SetConsoleColor( CC_LIGHTBLUE );
    		printf( "[DEBUG]: " );
    		break;
    	}
    
    	SetConsoleColor( CC_WHITE );
    
    	lConsole.lock( );
    	vprintf( format, arglist );
    	printf( ( flag == MSG_LOAD ) ? "\r" : "\n" );
    	
    	FILE *fh;
    	fopen_s( &fh, "log/logger.log", "a+" );
    	if ( fh != NULL ) {
    		vfprintf( fh, format, arglist );
    		fputc( '\n', fh );	
    		fclose( fh );
    	}	
    	
    	lConsole.unlock( );
    
    	va_end( arglist );
    }
    
    Thursday, January 20, 2011 4:10 PM
  • On 1/20/2011 11:10 AM, FaceofDevil wrote:

    boost::mutex::scoped_lock lConsole( mConsole, false );

    http://www.boost.org/doc/libs/1_45_0/doc/html/boost/interprocess/scoped_lock.html

    There's no scoped_lock constructor that expects a bool as its second parameter, as far as I can tell.


    Igor Tandetnik

    Thursday, January 20, 2011 7:11 PM
  • any suggestion to what i can change it too. my scope_lock is from 1_34_0 constructor so i was trying to update it to the lastest version...
    Thursday, January 20, 2011 11:24 PM
  • On 1/20/2011 6:24 PM, FaceofDevil wrote:

    any suggestion to what i can change it too.

    No idea. I'm not familiar with Boost. If no one else answers here, you might want to consider asking on Boost forums (I assume they them in some form).


    Igor Tandetnik

    Friday, January 21, 2011 2:24 AM
  • Hi FaceofDevil,

    In Visual C++ General Forum, we discuss general questions about Visual C++ , including the development environment, libraries, setup, debugger, samples, and documentation.

    For your future concerns, I recommend you post your question to Boost Forum: http://boost.2283326.n4.nabble.com/ .

    Thank you for your understanding.

     

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 7, 2011 9:49 AM