You are not logged in.

#1 2010-10-13 16:33:15

AcId
Member
Registered: 2009-07-11
Posts: 25

[SOLVED] Question about GCC error messages.

I'm currently taking a course in C programming, and I have  a question about the error messages returned by GCC.

When ever i try to compile a program containing syntax errors, i get cryptic and not very helpfull error messages.

If i try to compile:

#include <stdio.h>

int main(void)
{
        int i;

        i = 0
        return 0;
}

I get following from GCC:

error.c: In function â:
error.c:8:2: error: expected â before â

But shouldn't the message be something like:

error.c: In function 'main':
error.c:8:2: error: expected ; before 'return'

or am I mistaken?


/AcId

Last edited by AcId (2010-10-13 17:48:19)

Offline

#2 2010-10-13 16:48:00

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: [SOLVED] Question about GCC error messages.

Woah. That is very strange. I've never seen that before.

I assume you're using Arch Linux. What text editor did you use to write the code? Which terminal application are you using?

...those questions are probably unrelated to the problem, but we might as well get them out of the way. tongue

Offline

#3 2010-10-13 16:48:56

adee
Member
From: The Moon
Registered: 2009-11-10
Posts: 110

Re: [SOLVED] Question about GCC error messages.

adee ~ $ gcc s.c
s.c: In function 'main':
s.c:8:9: error: expected ';' before 'return'

Yes the ; is missing! The ; character is changed in your compile output, don't know why
And the Main is also changed......  strange

Last edited by adee (2010-10-13 16:50:53)

Offline

#4 2010-10-13 16:52:33

AcId
Member
Registered: 2009-07-11
Posts: 25

Re: [SOLVED] Question about GCC error messages.

Ofc I'm using Arch wink

I use GNU Emacs for all my coding, and xterm as terminal application.

Also, my current locale settings are en_DK.UTF8, anyone know if that might pose a problem?

Offline

#5 2010-10-13 17:37:50

AcId
Member
Registered: 2009-07-11
Posts: 25

Re: [SOLVED] Question about GCC error messages.

It seems the problem is only when running GCC in xterm inside X, if I run it in console, it prints errormessages just fine.

/AcId

Offline

#6 2010-10-13 17:47:49

AcId
Member
Registered: 2009-07-11
Posts: 25

Re: [SOLVED] Question about GCC error messages.

I located the error. Apparently Xlib doesn't support locale en_DK.UTF8, so changed it to en_US.UTF8 smile

Thanks for the help guys smile

Offline

Board footer

Powered by FluxBB