Search code examples
c++boostboost-coroutine

Does boost coroutine not work on Windows x86_64?


I compiled the example parallel.cpp that ships with boost::coroutines::coroutine both as 32-bit and 64-bit program.

They both compile and link without errors. The 32-bit program runs and behaves as expected but the 64-bit app crashes upon launch.

Using Visual Studio 2012 Express on Windows 7 64-bit.

EDIT: coroutine has been accepted into boost but not released as part of the boost distribution yet. I used the example from the author's 'final' version.

EDIT: This is the code

#include <boost/bind.hpp>
#include <boost/coroutine/all.hpp>

typedef boost::coroutines::coroutine< void() > coroutine_t;

void first( coroutine_t::caller_type & self)
{
    std::cout << "started first! ";
    for ( int i = 0; i < 10; ++i)
    {
        self();
        std::cout << "a" << i;
    }
}

void second( coroutine_t::caller_type & self)
{
    std::cout << "started second! ";
    for ( int i = 0; i < 10; ++i)
    {
        self();
        std::cout << "b" << i;
    }
}

int main( int argc, char * argv[])
{
    {
        coroutine_t c1( boost::bind( first, _1) );
        coroutine_t c2( boost::bind( second, _1) );
        while ( c1 && c2) {
            c1();
            std::cout << " ";
            c2();
            std::cout << " ";
        }
    }

    std::cout << "\nDone" << std::endl;

    return EXIT_SUCCESS;
}

Solution

  • use last version from boost-trunk - contains the latest versions of boost.coroutine + boost.context (used by boost.coroutine for context swapping) try to build the unit-tests (/libs/coroutine/test) first