I have been working on C++ for few years now and have compiled stuff several times but the following issue is totally new to me and it just doesn't make sense.
Following are the steps i am following:
- using cygwin setup with g++ version:6.4.0 and clang++ version:4.0.1
- created a new cpp fie using sublime text added simple cout and compiled
with the command: clang++ -g -Wall -std=c++14 thread1.cpp -o thread, works fine. - added new contents maybe another cout, this time upon compilation i get a ton of errors stating its not utf-8 file.
- saved the file using utf-8 encoding in sublime text and also tried with utf-8 BOM encoding, still getting same not utf-8 file error.
- ran the file command in cygwin to check file encoding , file -i thread1.cpp, got output as thread1.cpp: text/x-c; charset=utf-8.
Any pointers to what might be going wrong here?
Following is the code which compiles:
#include "iostream"
#include "thread"
#include "mutex"
using namespace std;
class threadFunctor{
public:
};
int main(int argc , char** argv){
cout << "Hello";
return 0;
}
Following code gives error:
#include "iostream"
#include "thread"
#include "mutex"
using namespace std;
class threadFunctor{
public:
};
int main(int argc , char** argv){
cout << "Hello World";
return 0;
}
Following is a snippet of the errors generated:
./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>.