[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

C Compiler?

TheInquisitiveSoul

9/8/2011 7:59:00 AM

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?
11 Answers

robertwessel2@yahoo.com

9/8/2011 9:17:00 AM

0

On Thu, 8 Sep 2011 07:59:15 +0000 (UTC), TheInquisitiveSoul
<theunknowable@lavabit.com> wrote:

>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?


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.

So on Windows, the (free) MS compiler (look for Visual Studio
Express). On Linux, GCC.

Rui Maciel

9/8/2011 9:59:00 AM

0

Robert Wessel wrote:

> 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

August Karlstrom

9/8/2011 12:39:00 PM

0

On 2011-09-08 09:59, TheInquisitiveSoul wrote:
> 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

--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra

Nomen Nescio

9/8/2011 12:42:00 PM

0

Rui Maciel <rui.maciel@gmail.com> wrote:

> Robert Wessel wrote:
>
> > 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"?

Duh...



August Karlstrom

9/8/2011 12:45:00 PM

0

On 2011-09-08 14:39, August Karlstrom wrote:
> 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

--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra

Rui Maciel

9/8/2011 3:02:00 PM

0

August Karlstrom wrote:

> On 2011-09-08 14:39, August Karlstrom wrote:
>> 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
<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.cg...


Rui Maciel

Rui Maciel

9/8/2011 3:47:00 PM

0

Rui Maciel wrote:

> 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.cg...

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.cg...

jacob navia

9/8/2011 3:52:00 PM

0

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


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

Kenneth Brody

9/8/2011 4:13:00 PM

0

On 9/8/2011 8:44 AM, August Karlstrom wrote:
> On 2011-09-08 14:39, August Karlstrom wrote:
>> 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.

FYI -

This is what MSVC 2010 gives:

==========
C:\temp>cl /c /W4 usenet.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

usenet.c
usenet.c(5) : error C2628: 't' followed by 'int' is illegal (did you forget
a ';'?)

C:\temp>
==========


--
Kenneth Brody

Ben Bacarisse

9/9/2011 12:30:00 AM

0

August Karlstrom <fusionfile@gmail.com> writes:

> On 2011-09-08 14:39, August Karlstrom wrote:
>> 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.

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.

--
Ben.