user1476982
user1476982

Reputation: 11

Undefined namespace 'boost'

I'm trying an C++ small thread program but having error that i couldn't handle it.

The Code

#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;

The Error

Test.cpp:15:21: error: ‘boost’ is not a namespace-name Test.cpp:15:26: error: expected namespace-name before ‘;’ token

The declaration of Thread Class

    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); }

     };

Upvotes: 0

Views: 515

Answers (1)

CB Bailey
CB Bailey

Reputation: 791699

You should delete the line using namespace boost;. It doesn't appear to be needed in your program.

Upvotes: 1

Related Questions