This is the mail archive of the
mailing list for the GCC project.
Re: weird characters in compiler warnings output
- From: Brian Dessent <brian at dessent dot net>
- To: "Abarbanel, David (US SSA)" <david dot abarbanel at baesystems dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 21 Aug 2006 17:24:23 -0700
- Subject: Re: weird characters in compiler warnings output
- References: <4A01140D15A9034D9D87CB1ADBFF64D454539B@EX-SRV-01.silverlnk.net>
- Reply-to: gcc-help at gcc dot gnu dot org
"Abarbanel, David (US SSA)" wrote:
> I am running gcc v4.1.1 on linux 2.4 and was wondering why I am seeing weird characters around certain identifiers when warnings are printed. Is this normal? See the example below:
> test.cpp: In function âint main()â:
> test.cpp:7: error: âcoutâ was not declared in this scope
> test.cpp:7: error: âendlâ was not declared in this scope
This means that you have a discrepancy between your locale settings and
the terminal you are using. For example, many distros set the locale
environment variables (LC_*) in the .bashrc type startup files to
something like en_US.UTF-8 by default. This tells programs to use US
English messages (and sorting collations, etc.) with UTF-8 encoding.
But if your terminal does not support the UTF-8 you will get garbage
characters when the program tries to use any code points outside of the
ascii range, in this case opening and closing quotes.
The solution is to set your locale to match the capabilities of the
terminal that you are using. If you can't figure this out you can
always use the default POSIX/C locale (e.g. "export LC_ALL=C") which
will only use standard ascii characters.
This has nothing to do with the functionality of gcc or the code it
generates, only messages that it prints.