这个错误很低级,但是也让我当时百思不得其解
semaphore.h
#ifndef SEMAPHORE_H
#define SEMAPHORE_H
#include <QSemaphore>
#include <QThread>
const int DataSize = 1000;
const int BufferSize = 80;
int buffer[BufferSize];
QSemaphore freeBytes(BufferSize);
QSemaphore usedBytes(0);
class Producer : public QThread
{
public:
Producer();
void run();
};
class Consumer : public QThread
{
public:
Consumer();
void run();
};
#endif
错误就在这里了,一开始我都不敢相信,这里怎么会出现重定义的报错呢???
错误原因
.h中只能声明,不能定义。。。