(This is not a question about a compile error, but about the Linux terminal setting.)

During any compile error, the error statement doesn't properly display code fragments:

In member function â:
error: â was not declared in this scope

Is there a setting to get my terminal to properly show:

In member function `foo()':
error: `endl' was not declared in this scope

More info: This shows-up in Emacs compile mode correctly, but even saving that buffer to a temporary file and reading it on the command-line produces the above characters. Reading that file in Vim shows that the strange characters represent more than one column of text.


I think you should first check the locale settings with:


If it is not aligned with the character set of the file then you might be getting errors, as such.

file yoursrcfile

should provide you with the necessary information.

There is the case also that your compiler is running with a different locale. You can workaround this by setting

export LC_ALL=en_US

for your bash session. This can be placed in front of the compilation command as well. e.g.

LC_ALL=en_US gcc -o outfile srcfile.c

But the effect in that case will be only on the subsequent command.

Another case is that probably your source code may have been edited in windows maybe? Anyhow it might contain some weird characters for some reason.

You should check it in vim by enabling to show all characters

:set invlist

Hope this helps!

  • To clarify, it's not the source file that displays odd characters, it's the compiler error lines that appear in the terminal. The source file is fine. The problems above only appear if I have a compile error, like a syntax mistake. But that's just a red herring. The real issue is the terminal and the above is simply a consistent symptom. – chrisaycock Mar 29 '11 at 23:24
  • you mean that if you just cat the source file the output is ok? – g24l Mar 30 '11 at 0:44
  • @g24l Yes, the source file is fine. Only the error message from the compiler when displayed on the terminal is messed-up. I can compile my program by correcting a simple and unrelated syntax mistake. I was just curious as to why the terminal displays the characters incorrectly when output as part of a compiler error. – chrisaycock Mar 30 '11 at 3:02
  • probably the compiler is running with a different locale. try inserting at the front of the command line something like LC_ALL=en_US or whatever you think appropriate. – g24l Mar 31 '11 at 0:41
  • @g24l LC_ALL=en_US worked! Edit your answer so I can accept it! – chrisaycock Mar 31 '11 at 1:58

If environment variable LANG is


then in the PuTTy Window Translation menu, in

"Received data assumed to be in which character set", select


or set LANG to just



unset LANG

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.