Я пробовал программу с небольшим потоком C++, но имею ошибку, с которой я не мог справиться.Undefined namespace 'boost'
Кодекс
#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: ошибка: 'повышение' не-пространство имен test.cpp: 15: 26: ошибка: ожидается Пространство имен имя-до '' лексема
декларация класса Thread
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 ... –
/me захватывает свой хрустальный шар ... Каковы содержимое Threads.h и Interthread.h? Как мы должны реагировать на это, не зная, что там? – Griwes
@OliCharlesworth Я не знаю заголовка boost и не могу его найти. – user1476982