A
albert.neu
Hello!
What is a good compiler to use? (for MS Windows, for Linux)
Any recommendations??
What's the point of having a C99 standard, if different compilers
still produce differing results?
The main reason for a standard, is (in my opinion) portabilty and
conformance.
/************** C99 Resources ***************/
C99 Standard(Committee Draft 2005 - ISO/IEC 9899:TC2)
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
"The New C Standard: A Cultural and Economic Commentary" by Derek M.
Jones
http://www.coding-guidelines.com/cbook/cbook1_0b.pdf
(http://www.knosof.co.uk/cbook/cbook.html)
This is the ultimate C99 reference bible, since it discusses every
sentance of the C99 standard. Wow!
But no one seems to care:
I recently tried a bunch of *free* compilers...
MinGW GCC (no C99 support e.g. printf("%I64d",99999999LL)),
Lcc-Win32,
Pelles C,
Cygwin GCC
and got different results for the same code snippet
/***********************/
#include <stdio.h>
#include <math.h>
int main(void)
{
printf("%f\n", sqrt(4.0L));
printf("%lf\n", sqrt(4.0L));
printf("%Lf\n", sqrt(4.0L)); // printf("%Lf\n", (long
double)sqrt(4.0L));
return 0;
}
/***********************/
(There are probably much better examples, to show how compilers
differ!
I'm (currently) no expert in C, and certainly not on the C99 standard.
(I wonder if the C99 standard specifies, what the ouput of the 3rd
printf should be...)
I get really frustrated when even printf (yes, that "Hello World"
function) differs from implementation to implementation.
printf("%hhd %hd %d %lld", a, b, c, d); // I wonder how many compilers
support this (C99) correctly... try MinGW
But if I use a compiler, I expect it to work! and to have predicatable
behaviour! and to implement the C99 standard!
I think C99 has failed, if only a few compilers support it.
(Perennial http://www.peren.com/ conducts conformance tests and only a
handful of compilers are validated as C99-compliant:
http://www.peren.com/pages/cvsa_isocvpl.htm)
Sun Studio 9 seems to be the only free compiler out there, that fully
supports C99. (Wow, maby I should learn and use Solaris)
For the rest... everyone else seems to be doing their own thing:
Microsoft Visual C++ are doing theirs... GCC is doing theirs... and so
on
No one seems to be really interested in following the C99 standard.
Instead everyone is happy to have a compiler that can simply produce
code (C99 is probably an ugly cryptic read anyway) and the game seems
to be played as follows:
"Forget portability! and code for the moment! Adapt your code, till it
works, with the compiler you're using.
If it needs to be ported, do it when it's necessary. Hell, the
compilers will have changed anyway!!"
???
Maby I should follow suit: Code and test it with your compiler, (be
puzzled for a moment), debug and done!
************************>>>
By the way: who is involved in the C99 standard?
Why didn't they invite C compiler writers (Visual C, GCC, Watcom) to
take part??? Is C99 really that hard to implement?
Ok, what about commercial products for C99?
***
Ah, there's Dinkumware (http://www.dinkumware.com/)
They have a library "Dinkum Compleat" that can be bought for either MS
Windows Visual C++ ($200) or Linux GCC ($200) and allows C99 in
addition to many other things (you cannot get the C99 part
seperately). That library can be bought in binary ($200 "Dinkum
Compleat Libraries Binary" for Visual C++ xor Linux GCC, or $400 for
both) or source form ($2300) and is Perennial C99 compliant (see
http://www.peren.com).
***
Ah, there's Comeau C/C++. http://www.comeaucomputing.com/
What an ugly web-page! Ugly use of font, and waving a blinking $50 at
me!
It seems as though Dinkumware libraries are included... oops no
(fooled me)... they are only available... from Dinkumware... for $200
So it seems I need to spend $ (50+200) for Comeau C/C++ with
Dinkumware for C99 compliance.
(Libcomo seems to be Comeau's own C library, but I could not find a
price - and it probably doesn't support C99.)
Ah but wait, in order to use Comeau, I need another compiler... What
is this beast!????
For MS windows: e.g. "Comeau C/C++" & "Visual C++" & "Dinkumware
Libraries" for C99
For Linux: e.g. "Comeau C/C++" & "GCC" & "Dinkumware Libraries" for
C99
OK, so "Comeau C/C++" works like this:
It is a front end that takes your C-code (C1) and generates an
"Intermediate Form" and from that another C code (C2).
Then you use another compiler (Visual C++, or GCC) to compile C2 to
"machine code".
"Comeau C/C++" don't even have their own machine code generator.
I don't see why anyone would use Comeau...
***
Ah, Edison Design Group: http://www.edg.com/ http://www.edg.com/index.php?location=c_frontend
These 4 guys have a front-end that supports C99 (see also
http://www.peren.com/pages/cvsa_isocvpl.htm)
Intel's C++ compiler's front end is based on EDG, as is Comeau's
(http://www.edg.com/index.php?location=faq_q3_who)
Does this mean that Comeau is C99 compliant? (Who knows?:
http://www.thescripts.com/forum/threadnav219651-1-10.html)
SUIF and Zephyr also use EDG
http://www.edg.com/index.php?location=faq_q4_other
Does anyone know if SUIF (with matching EDG front-end
http://suif.stanford.edu/~livshits/cgi-bin/clickthru.cgi) is good?
http://www-suif.stanford.edu/suif/suif2/
Are there any compiler recommendations...
Right now I'm unwilling to use commercial tools.
I think I'll just stick with GCC (in its various forms: Linux, Cygwin,
MinGW) and play the game, accepting that things just aren't perfect.
Any comments or recommendations, tips etc. will be appreciated
Kind regards,
Albert
What is a good compiler to use? (for MS Windows, for Linux)
Any recommendations??
What's the point of having a C99 standard, if different compilers
still produce differing results?
The main reason for a standard, is (in my opinion) portabilty and
conformance.
/************** C99 Resources ***************/
C99 Standard(Committee Draft 2005 - ISO/IEC 9899:TC2)
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
"The New C Standard: A Cultural and Economic Commentary" by Derek M.
Jones
http://www.coding-guidelines.com/cbook/cbook1_0b.pdf
(http://www.knosof.co.uk/cbook/cbook.html)
This is the ultimate C99 reference bible, since it discusses every
sentance of the C99 standard. Wow!
But no one seems to care:
I recently tried a bunch of *free* compilers...
MinGW GCC (no C99 support e.g. printf("%I64d",99999999LL)),
Lcc-Win32,
Pelles C,
Cygwin GCC
and got different results for the same code snippet
/***********************/
#include <stdio.h>
#include <math.h>
int main(void)
{
printf("%f\n", sqrt(4.0L));
printf("%lf\n", sqrt(4.0L));
printf("%Lf\n", sqrt(4.0L)); // printf("%Lf\n", (long
double)sqrt(4.0L));
return 0;
}
/***********************/
(There are probably much better examples, to show how compilers
differ!
I'm (currently) no expert in C, and certainly not on the C99 standard.
(I wonder if the C99 standard specifies, what the ouput of the 3rd
printf should be...)
I get really frustrated when even printf (yes, that "Hello World"
function) differs from implementation to implementation.
printf("%hhd %hd %d %lld", a, b, c, d); // I wonder how many compilers
support this (C99) correctly... try MinGW
But if I use a compiler, I expect it to work! and to have predicatable
behaviour! and to implement the C99 standard!
I think C99 has failed, if only a few compilers support it.
(Perennial http://www.peren.com/ conducts conformance tests and only a
handful of compilers are validated as C99-compliant:
http://www.peren.com/pages/cvsa_isocvpl.htm)
Sun Studio 9 seems to be the only free compiler out there, that fully
supports C99. (Wow, maby I should learn and use Solaris)
For the rest... everyone else seems to be doing their own thing:
Microsoft Visual C++ are doing theirs... GCC is doing theirs... and so
on
No one seems to be really interested in following the C99 standard.
Instead everyone is happy to have a compiler that can simply produce
code (C99 is probably an ugly cryptic read anyway) and the game seems
to be played as follows:
"Forget portability! and code for the moment! Adapt your code, till it
works, with the compiler you're using.
If it needs to be ported, do it when it's necessary. Hell, the
compilers will have changed anyway!!"
???
Maby I should follow suit: Code and test it with your compiler, (be
puzzled for a moment), debug and done!
************************>>>
By the way: who is involved in the C99 standard?
Why didn't they invite C compiler writers (Visual C, GCC, Watcom) to
take part??? Is C99 really that hard to implement?
Ok, what about commercial products for C99?
***
Ah, there's Dinkumware (http://www.dinkumware.com/)
They have a library "Dinkum Compleat" that can be bought for either MS
Windows Visual C++ ($200) or Linux GCC ($200) and allows C99 in
addition to many other things (you cannot get the C99 part
seperately). That library can be bought in binary ($200 "Dinkum
Compleat Libraries Binary" for Visual C++ xor Linux GCC, or $400 for
both) or source form ($2300) and is Perennial C99 compliant (see
http://www.peren.com).
***
Ah, there's Comeau C/C++. http://www.comeaucomputing.com/
What an ugly web-page! Ugly use of font, and waving a blinking $50 at
me!
It seems as though Dinkumware libraries are included... oops no
(fooled me)... they are only available... from Dinkumware... for $200
So it seems I need to spend $ (50+200) for Comeau C/C++ with
Dinkumware for C99 compliance.
(Libcomo seems to be Comeau's own C library, but I could not find a
price - and it probably doesn't support C99.)
Ah but wait, in order to use Comeau, I need another compiler... What
is this beast!????
For MS windows: e.g. "Comeau C/C++" & "Visual C++" & "Dinkumware
Libraries" for C99
For Linux: e.g. "Comeau C/C++" & "GCC" & "Dinkumware Libraries" for
C99
OK, so "Comeau C/C++" works like this:
It is a front end that takes your C-code (C1) and generates an
"Intermediate Form" and from that another C code (C2).
Then you use another compiler (Visual C++, or GCC) to compile C2 to
"machine code".
"Comeau C/C++" don't even have their own machine code generator.
I don't see why anyone would use Comeau...
***
Ah, Edison Design Group: http://www.edg.com/ http://www.edg.com/index.php?location=c_frontend
These 4 guys have a front-end that supports C99 (see also
http://www.peren.com/pages/cvsa_isocvpl.htm)
Intel's C++ compiler's front end is based on EDG, as is Comeau's
(http://www.edg.com/index.php?location=faq_q3_who)
Does this mean that Comeau is C99 compliant? (Who knows?:
http://www.thescripts.com/forum/threadnav219651-1-10.html)
SUIF and Zephyr also use EDG
http://www.edg.com/index.php?location=faq_q4_other
Does anyone know if SUIF (with matching EDG front-end
http://suif.stanford.edu/~livshits/cgi-bin/clickthru.cgi) is good?
http://www-suif.stanford.edu/suif/suif2/
Are there any compiler recommendations...
Right now I'm unwilling to use commercial tools.
I think I'll just stick with GCC (in its various forms: Linux, Cygwin,
MinGW) and play the game, accepting that things just aren't perfect.
Any comments or recommendations, tips etc. will be appreciated
Kind regards,
Albert