gcc: error: stray ‘\342’ in program
Thursday, April 17th, 2008
Lately I have been worried about a strange error message I have been getting from gcc, while trying to compile small C programs for my school's assignment.
The errors were of this form:
I couldn't see any obvious syntactical error in the mentioned line. This is how line #57 looks like:
At first sight, it looks pretty fine, but if you look closely you will see that the double quotation marks that surround the string literal are not the neutral (vertical) ones (like this: "). They are left and right double quotation marks respectively.
If I replace the quotation marks with the neutral ones, like this:
the problem is solved. So, if you are getting this kind of error maybe you should look closely to any double (or single) quotation marks in the erroneous line.
It is worth to say that I only had this problem when copying and pasting from the PDF files of my school, which were mostly likely exported by Micro$oft Word, which in turn had probably screwed the double quotation lines.
The errors were of this form:
giannis@giannis-vbox:~$ gcc program.c
program.c: In function ‘main’:
program.c:57: error: stray ‘\342’ in program
program.c:57: error: stray ‘\200’ in program
program.c:57: error: stray ‘\234’ in program
program.c:57: error: stray ‘\’ in program
...I couldn't see any obvious syntactical error in the mentioned line. This is how line #57 looks like:
printf(“\nThe linked list representation is...\n”);At first sight, it looks pretty fine, but if you look closely you will see that the double quotation marks that surround the string literal are not the neutral (vertical) ones (like this: "). They are left and right double quotation marks respectively.
If I replace the quotation marks with the neutral ones, like this:
printf("\nThe linked list representation is...\n");the problem is solved. So, if you are getting this kind of error maybe you should look closely to any double (or single) quotation marks in the erroneous line.
It is worth to say that I only had this problem when copying and pasting from the PDF files of my school, which were mostly likely exported by Micro$oft Word, which in turn had probably screwed the double quotation lines.