未定义的命名空间'boost' [英] Undefined namespace 'boost'
本文介绍了未定义的命名空间'boost'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试一个C ++小线程程序,但有错误,我无法处理它。
I'm trying an C++ small thread program but having error that i couldn't handle it.
代码
#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:错误:期望的命名空间名称';'token
Test.cpp:15:21: error: ‘boost’ is not a namespace-name Test.cpp:15:26: error: expected namespace-name before ‘;’ token
线程类的声明
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); }
};
推荐答案
您应该删除使用命名空间boost;
。它似乎不需要在您的程序。
You should delete the line using namespace boost;
. It doesn't appear to be needed in your program.
这篇关于未定义的命名空间'boost'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文