Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gcc errors in compiler output

23 views
Skip to first unread message

Julianne

unread,
Dec 26, 2009, 7:05:18 PM12/26/09
to
When using emacs 23.1 on Fedora 12, compiling a simple c file with an
error yields the following output:


gcc -o my_test my_test.c
my_test.c: In function ‘main’:
my_test.c:58: error: expected ‘;’ before ‘x’

If I run the compiler in an ordinary xterm (or Konsole), the output
appears to be some colorization of the identifiers in the context of the
error.

The hex dump shows the missing charaters:

6d 79 5f 74 65 73 74 2e 63 3a 20 49 6e 20 66 75 |my_test.c: In fu|
6e 63 74 69 6f 6e 20 e2 80 98 6d 61 69 6e e2 80 |nction ...main..|
99 3a 0a 6d 79 5f 74 65 73 74 2e 63 3a 35 38 3a |.:.my_test.c:58:|
20 65 72 72 6f 72 3a 20 65 78 70 65 63 74 65 64 | error: expected|
20 e2 80 98 3b e2 80 99 20 62 65 66 6f 72 65 20 | ...;... before |
e2 80 98 78 e2 80 99 0a |...x....|

What is the solution to either a) get gcc to not output terminal color
settings around identifiers or b) make emacs ignore the extraneous stuff
around the identifiers?

Julianne

Pascal J. Bourguignon

unread,
Dec 26, 2009, 8:01:22 PM12/26/09
to
Julianne <julia...@gmail.com> writes:

> When using emacs 23.1 on Fedora 12, compiling a simple c file with an
> error yields the following output:
>
>
> gcc -o my_test my_test.c
> my_test.c: In function ‘main’:
> my_test.c:58: error: expected ‘;’ before ‘x’
>
> If I run the compiler in an ordinary xterm (or Konsole), the output
> appears to be some colorization of the identifiers in the context of
> the error.

That's where your error lies. It is not a colorization, but an
encoding in utf-8 of the characters ‘ and ’:

my_test.c: In function ‘main’:
my_test.c:58: error: expected ‘;’ before ‘x’


> The hex dump shows the missing charaters:
>
> 6d 79 5f 74 65 73 74 2e 63 3a 20 49 6e 20 66 75 |my_test.c: In fu|
> 6e 63 74 69 6f 6e 20 e2 80 98 6d 61 69 6e e2 80 |nction ...main..|
> 99 3a 0a 6d 79 5f 74 65 73 74 2e 63 3a 35 38 3a |.:.my_test.c:58:|
> 20 65 72 72 6f 72 3a 20 65 78 70 65 63 74 65 64 | error: expected|
> 20 e2 80 98 3b e2 80 99 20 62 65 66 6f 72 65 20 | ...;... before |
> e2 80 98 78 e2 80 99 0a |...x....|

I see no missing character here.


> What is the solution to either a) get gcc to not output terminal color
> settings around identifiers or b) make emacs ignore the extraneous
> stuff around the identifiers?

Configure the same encoding in your terminal and in your shell!


If your terminal handles UTF-8:

[pjb@hubble :0.0 tmp]$ export LC_CTYPE=en_US.UTF-8
[pjb@hubble :0.0 tmp]$ cc -c -o a.o a.c
a.c: In function ‘main’:
a.c:3: error: expected ‘;’ before ‘x’


If your terminal handles ISO-8859-1:

[pjb@hubble :0.0 tmp]$ export LC_CTYPE=en_US.ISO-8859-1
[pjb@hubble :0.0 tmp]$ cc -c -o a.o a.c
a.c: In function 'main':
a.c:3: error: expected ';' before 'x'

etc...


--
__Pascal Bourguignon__ http://www.informatimago.com/

to...@tuxteam.de

unread,
Dec 27, 2009, 1:36:44 AM12/27/09
to help-gn...@gnu.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, Dec 27, 2009 at 02:01:22AM +0100, Pascal J. Bourguignon wrote:
> Julianne <julia...@gmail.com> writes:
>
> > When using emacs 23.1 on Fedora 12, compiling a simple c file with an
> > error yields the following output:

[...]

> That's where your error lies. It is not a colorization, but an
> encoding in utf-8 of the characters ‘ and ’:

[...]

> [pjb@hubble :0.0 tmp]$ export LC_CTYPE=en_US.ISO-8859-1
> [pjb@hubble :0.0 tmp]$ cc -c -o a.o a.c
> a.c: In function 'main':
> a.c:3: error: expected ';' before 'x'

Exactly. Since ggcc 4.0 [1], the output of GCC is uTF-8, if the locale
allows. So your best bet is to do what Pascal suggests or even more
radically call "LC_ALL = C gcc" instead of just "gcc" to turn off this
"feature". You might tweak the environment your compile subprocess sees
with setenv in Emacs.

[1] See <http://gcc.gnu.org/gcc-4.0/changes.html> under "Caveats", and
search for the phrase "English-language diagnostic messages".

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFLNwB8Bcgs9XrR2kYRApY9AJ90QCq+fXjTpFWEmXtL59IDN9QlmACfWs+I
7q1omxN3iDIdxhUkR2aDS3I=
=cUwj
-----END PGP SIGNATURE-----


Vagn Johansen

unread,
Dec 27, 2009, 5:21:22 PM12/27/09
to
Julianne <julia...@gmail.com> writes:

> When using emacs 23.1 on Fedora 12, compiling a simple c file with an
> error yields the following output:
>
>
> gcc -o my_test my_test.c
> my_test.c: In function ‘main’:
> my_test.c:58: error: expected ‘;’ before ‘x’
>

[...]


See also

http://groups.google.co.zm/group/gnu.emacs.help/browse_thread/thread/5b78cc295848008f
"linux/gcc, apostrophs display problem"
--
Vagn Johansen

0 new messages