I am having a bit of a trouble with gcc. I wrote a simple Hello World C++ program:
#include <iostream>
int main()
{
cout<<“Hello World”;
return 0;
}
When I tried to compile this using gcc. I got a long list of errors:
/usr/include/ctype.h:52: error: stray ‘\370’ in program
/usr/include/ctype.h:52: error: stray ‘`’ in program
/usr/include/ctype.h:52: error: stray ‘\216’ in program
/usr/include/ctype.h:52: error: stray ‘\10’ in program
/usr/include/ctype.h:52: error: stray ‘\4’ in program
/usr/include/ctype.h:52: error: stray ‘\20’ in program
/usr/include/ctype.h:52: error: stray ‘\215’ in program
/usr/include/ctype.h:52: error: stray ‘\10’ in program
/usr/include/ctype.h:52: error: stray ‘\215’ in program
/usr/include/ctype.h:52: error: stray ‘\350’ in program
/usr/include/ctype.h:52: error: stray ‘\323’ in program
/usr/include/ctype.h:52: error: stray ‘\201’ in program
/usr/include/ctype.h:52: error: stray ‘\1’ in program
/usr/include/ctype.h:52: error: stray ‘\205’ in program
/usr/include/ctype.h:52: error: stray ‘\300’ in program
/usr/include/ctype.h:52: error: stray ‘\7’ in program
/usr/include/ctype.h:52: error: stray ‘\270’ in program
/usr/include/ctype.h:52: error: stray ‘\1’ in program
/usr/include/ctype.h:52: error: stray ‘\353’ in program
/usr/include/ctype.h:52: error: stray ‘\2’ in program
/usr/include/ctype.h:52: error: stray ‘\300’ in program
/usr/include/ctype.h:52: error: stray ‘\215’ in program
/usr/include/ctype.h:52: error: stray ‘\350’ in program
/usr/include/ctype.h:52: error: stray ‘\211’ in program
/usr/include/ctype.h:52: error: stray ‘\354’ in program
/usr/include/ctype.h:52: error: stray ‘\303’ in program
/usr/include/ctype.h:52: error: stray ‘\215’ in program
/usr/include/ctype.h:52: error: stray ‘\266’ in program
/usr/include/ctype.h:52: error: stray ‘\215’ in program
/usr/include/ctype.h:52: error: stray ‘\274’ in program
/usr/include/ctype.h:52: error: missing terminating ’ character
/usr/include/ctype.h:53: error: stray ‘\203’ in program
/usr/include/ctype.h:53: error: stray ‘\370’ in program
/usr/include/ctype.h:53: error: stray ‘\1’ in program
/usr/include/ctype.h:53: error: stray ‘\351’ in program
/usr/include/ctype.h:53: error: stray ‘\6’ in program
/usr/include/ctype.h:53: error: stray ‘\1’ in program
/usr/include/ctype.h:53: error: stray ‘\215’ in program
/usr/include/ctype.h:53: error: stray ‘\213’ in program
/usr/include/ctype.h:53: error: stray ‘\17’ in program
/usr/include/ctype.h:53: error: stray ‘\316’ in program
/usr/include/ctype.h:53: error: stray ‘\203’ in program
/usr/include/ctype.h:53: error: stray ‘\303’ in program
/usr/include/ctype.h:53: error: stray ‘\4’ in program
/usr/include/ctype.h:53: error: stray ‘\201’ in program
/usr/include/ctype.h:53: error: stray ‘\376’ in program
/usr/include/ctype.h:53: error: stray ‘\377’ in program
/usr/include/ctype.h:53: error: stray ‘\17’ in program
/usr/include/ctype.h:53: error: stray ‘\207’ in program
/usr/include/ctype.h:53: error: stray ‘\360’ in program
/usr/include/ctype.h:53: error: stray ‘\215’ in program
I thought I might have included some invalid characters in my cpp file, but the program itself is short and there were just too many errors. So I tried cpp preprocessor.
I found that it was including a file: /usr/include/wchar.h
This file is in binary form I think (shows symbols and wierd characters) and appears to be the cause of the issue. :sarcastic:
What am I using?
openSUSE 11.0
gcc 4.3
I am rather new at all this, so any help in this regard is much appreciated. Please let me know if additional info is needed.
it looks like there are some special characters in your source file (which aren’t displayed by your editor). I recommend retype these few lines again (do not copy). I had something similar before and as far as I remember this happened when i was copying some source code from a website the source files
I just realized that the error comes from an included file (sorry haven’t read with full attention), so something there could be malformed. Maybe it helps to reinstall glibc-devel or check the integrity of the installed files of glibc-devel with rpm -qV glibc-devel. It’s just a guess but maybe you find the solution there.
That did not work. I tried to reinstall gcc, unfortunately that did not resolve my problem. Uhmmm…:(, will need to take it up when I have a lot of leisure time…
(in your code above “std::” before cout was missing, so that cout was unknown for the compiler). The source file was named test.cpp. Then I simply compiled it with
g++ test.cpp
and it works without any issues. Maybe you can verify the steps and say if you are doing something different.
I tried using std:: before the cout, but it did not really make any difference…
I had added a line earlier, “using namespace std”, however I changed it to reflect what you had written… unfortunately that did not help. Do you think i need to completely re-install all the gcc packages??
maybe it helps when you can paste the complete compiler output somewhere (use pastebin - collaborative debugging tool or something else) maybe the errors come from somewhere else.
I’m currently running out of ideas. Maybe reinstalling the gcc packages solves this problem. It might be an encoding issue but I have no idea what exactly goes wrong.