C Compiler?

  • Thread starter TheInquisitiveSoul
  • Start date
T

TheInquisitiveSoul

Why, Hello everyone!

I want to learn the C Programming language, I'm currently on windows and
occasionally switch use Linux. What compiler do you guys recommend?

Mingw, PCC or Digital Mars compilers...

Looking for a pros and cons for each. MinGW seems temptings due to the
fact that GCC like most GNU software tends to be everywhere. PCC has
been in development for a lot longer and 'seems more stable?' I don't
know... Digitals Mars...I just heard of it somewhere.

Recommendations?
 
R

Rui Maciel

Robert said:
If you're learning the language, you want to avoid messing around with
the compilers too much, and stick with the most "natural" compiler for
each platform.

What's your definition of "most natural compiler for each platform"?


Rui Maciel
 
A

August Karlstrom

Why, Hello everyone!

I want to learn the C Programming language, I'm currently on windows and
occasionally switch use Linux. What compiler do you guys recommend?

Mingw, PCC or Digital Mars compilers...

Looking for a pros and cons for each. MinGW seems temptings due to the
fact that GCC like most GNU software tends to be everywhere. PCC has
been in development for a lot longer and 'seems more stable?' I don't
know... Digitals Mars...I just heard of it somewhere.

Recommendations?

For Linux I would recommend Clang. It has very informative error messages.


August
 
A

August Karlstrom

For Linux I would recommend Clang. It has very informative error messages.

Here is a comparison of Clang and GCC:

$ cat test.c
struct t {
int x;
}

int main(void)
{
return 0;
}

$ gcc -Wall -Wextra -ansi -pedantic test.c
test.c:5:1: error: two or more data types in declaration specifiers
test.c:5:5: warning: return type of ‘main’ is not ‘int’
test.c: In function ‘main’:
test.c:7:2: error: incompatible types when returning type ‘int’ but
‘struct t’ was expected
test.c:8:1: warning: control reaches end of non-void function

$ clang -Wall -Wextra -ansi -pedantic test.c
test.c:3:2: error: expected ';' after struct
}
^
;
1 error generated.


/August
 
R

Rui Maciel

August said:
Here is a comparison of Clang and GCC:

$ cat test.c
struct t {
int x;
}

int main(void)
{
return 0;
}

$ gcc -Wall -Wextra -ansi -pedantic test.c
test.c:5:1: error: two or more data types in declaration specifiers
test.c:5:5: warning: return type of ‘main’ is not ‘int’
test.c: In function ‘main’:
test.c:7:2: error: incompatible types when returning type ‘int’ but
‘struct t’ was expected
test.c:8:1: warning: control reaches end of non-void function
<snip/>

If anyone is interested, I've posted a bug report on GCC's bug report page
reflecting this problem. The bug report is available at:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50330


Rui Maciel
 
R

Rui Maciel

Rui said:
If anyone is interested, I've posted a bug report on GCC's bug report page
reflecting this problem. The bug report is available at:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50330

It appears that this problem has been fixed for a year or so. Taken from
gcc's bug report page[1], current gcc versions return the following error
message:

<message>
error: expected ';', identifier or '(' before 'int'
</message>

Not bad. I haven't tested it personally, though.


Rui Maciel


[1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50330
 
J

jacob navia

Le 08/09/11 17:01, Rui Maciel a écrit :


The lcc-win compiler has the same output as clang.
 
B

Ben Bacarisse

August Karlstrom said:
Here is a comparison of Clang and GCC:

$ cat test.c
struct t {
int x;
}

int main(void)
{
return 0;
}

$ gcc -Wall -Wextra -ansi -pedantic test.c
test.c:5:1: error: two or more data types in declaration specifiers
test.c:5:5: warning: return type of ‘main’ is not ‘int’
test.c: In function ‘main’:
test.c:7:2: error: incompatible types when returning type ‘int’ but
‘struct t’ was expected
test.c:8:1: warning: control reaches end of non-void function

$ clang -Wall -Wextra -ansi -pedantic test.c
test.c:3:2: error: expected ';' after struct
}
^
;
1 error generated.

I agree that gcc's message is confusing but it has the merit of being
correct -- there are (or appear to be) two data types in the declaration
specifiers for main!

gcc 4.6's new report (expected ';', identifier or '(' before 'int') is
possibly a little better than clang's because it is not certain that a
semicolon is missing. Clang should not really be expecting (only) a
semicolon. I suspect the message comes from the fact that adding a ; is
the least change that produces a valid parse.

However, I can't see why this message was corrected to include a few of
the things that might follow the declaration specifiers but not all of
them! As far as I can tell, it should read:

expected ';', identifier, '*' or '(' before 'int'

but I may have missed something -- it's basically any token that can
start a declarator.
 
G

Geoff

Here is a comparison of Clang and GCC:

$ cat test.c
struct t {
int x;
}

int main(void)
{
return 0;
}

$ gcc -Wall -Wextra -ansi -pedantic test.c
test.c:5:1: error: two or more data types in declaration specifiers
test.c:5:5: warning: return type of ‘main’ is not ‘int’
test.c: In function ‘main’:
test.c:7:2: error: incompatible types when returning type ‘int’ but
‘struct t’ was expected
test.c:8:1: warning: control reaches end of non-void function

$ clang -Wall -Wextra -ansi -pedantic test.c
test.c:3:2: error: expected ';' after struct
}
^
;
1 error generated.

Output from Visual Studio 2010:
main.c(5): error C2628: 't' followed by 'int' is illegal (did you
forget a ';'?)

Output from Xcode 4.1 (llvm compiler) in the GUI:
Parse Issue: Expected ';' after struct
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top