我已经在C ++上工作了几年,并且已经多次编译了这些东西,但是以下问题对我来说是全新的,它只是没有意义。
以下是我要遵循的步骤:
这里有什么可能出错的指针?
以下是编译的代码:
#include "iostream"
#include "thread"
#include "mutex"
using namespace std;
class threadFunctor{
public:
};
int main(int argc , char** argv){
cout << "Hello";
return 0;
}
以下代码给出错误:
#include "iostream"
#include "thread"
#include "mutex"
using namespace std;
class threadFunctor{
public:
};
int main(int argc , char** argv){
cout << "Hello World";
return 0;
}
以下是生成错误的片段:
./thread:3:29: error: source file is not valid UTF-8
$<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>PE<U+0000><U+0000>d<86><U+0014><U+0000><87><F5><CC>Y<U+0000><U+0014><U+0001><U+0000><A9><U+0002><U+0000><U+0000><F0><U+0000>'...
^
./thread:3:30: warning: null character ignored [-Wnull-character]
$<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>PE<U+0000><U+0000>d<86><U+0014><U+0000><87><F5><CC>Y<U+0000><U+0014><U+0001><U+0000><A9><U+0002><U+0000><U+0000><F0><U+0000>'...
^
./thread:3:31: warning: missing terminating ' character [-Winvalid-pp-token]
$<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>PE<U+0000><U+0000>d<86><U+0014><U+0000><87><F5><CC>Y<U+0000><U+0014><U+0001><U+0000><A9><U+0002><U+0000><U+0000><F0><U+0000>'...
^
./thread:4:3: warning: null character ignored [-Wnull-character]
5<U+0001><U+0000><U+0000><E8><B0><U+0001><U+0000><U+0000>E1<C0>1<D2>1<C9><E8><C4><U+0001><U+0000><U+0000>E1<C0>1<D2>1<C9><E8><C8><U+0001><U+0000><U+0000>E1<C0>1<D2>1<C9><E8><CC>...
^
./thread:4:4: warning: null character ignored [-Wnull-character]
5<U+0001><U+0000><U+0000><E8><B0><U+0001><U+0000><U+0000>E1<C0>1<D2>1<C9><E8><C4><U+0001><U+0000><U+0000>E1<C0>1<D2>1<C9><E8><C8><U+0001><U+0000><U+0000>E1<C0>1<D2>1<C9><E8><CC>...
^
./thread:4:5: error: source file is not valid UTF-8
5<U+0001><U+0000><U+0000><E8><B0><U+0001><U+0000><U+0000>E1<C0>1<D2>1<C9><E8><C4><U+0001><U+0000><U+0000>E1<C0>1<D2>1<C9><E8><C8><U+0001><U+0000><U+0000>E1<C0>1<D2>1<C9><E8><CC>.
答案 0 :(得分:6)
通过执行#include "thread"
,您已经(至少按照惯例)说明了thread
文件的当前目录。问题是您当前目录中有thread
个文件。据推测,它是您第一次编译时的可执行文件。错误显而易见,明确说明./thread
。
您应该通过#include <thread>
而非#include "thread"
包含所有标准标头 - 您绝不想先在其他地方搜索标准标头。