-1

C++ の小さなスレッド プログラムを試していますが、処理できないというエラーが発生しました。

コード

#include "Threads.h"
#include "Interthread.h"


void* task1(void *arg) {
// do stuff
}

void task2() {
// do stuff
}

int main (int argc, char ** argv) {
using namespace boost;
Thread thread_1;
thread_1.start (task1,NULL);
// Thread thread_2 = thread(task2);

// do other stuff
//thread_2.join();
thread_1.join ();
return 0;

エラー

Test.cpp:15:21: エラー: 'boost' は名前空間名ではありません Test.cpp:15:26: エラー: ';' の前に名前空間名が必要です トークン

スレッドクラスの宣言

    class Thread {

    private:

    pthread_t mThread;
    pthread_attr_t mAttrib;
    // FIXME -- Can this be reduced now?
    size_t mStackSize;


    public:

    /** Create a thread in a non-running state. */
    Thread(size_t wStackSize = (65536*4)):mThread((pthread_t)0) {mStackSize=wStackSize;}

    /**
            Destroy the Thread.
            It should be stopped and joined.
    */
    ~Thread() { int s = pthread_attr_destroy(&mAttrib); assert(s==0); }


    /** Start the thread on a task. */
    void start(void *(*task)(void*), void *arg);

    /** Join a thread that will stop on its own. */
    void join() { pthread_join(mThread,NULL); }

     };
4

1 に答える 1

1

行を削除する必要がありますusing namespace boost;。あなたのプログラムでは必要ないようです。

于 2012-06-23T15:24:02.373 に答える