Good shareware compiler for C?

K

Keith Thompson

Chris Saunders said:
Hi Keith

I'm not sure I understand your meaning. I consistantly "top post" and wish
others would. However I never comment on anothers posting style and am sure
that there are others that prefer this. I do not wish to maintain a
standard that I do not agree with. I'm sure this gives the "top posting
police" a fit but I will continue with my way. I'm not going to post again
on this topic as I don't think it is worth much discussion.

Read the following links:

http://www.caliburn.nl/topposting.html
http://www.cpax.org.uk/prg/writings/topposting.php

Then do what you want, but consider this: if you insist on
top-posting, this newsgroup will be much less useful to you than it
could have been. Your name is undoubtedly already in a number of
killfiles, and many people will refuse to answer your questions.

Note that we're not suggesting that you should quote an entire long
article followed by your response, so having to read through large
volumes of quoted text isn't an issue. You should trim the quoted
material, deleting anything that's not relevant to your followup.
There are thousands of examples in this newsgroup.

Some of us spend considerable time reading articles in this newsgroup.
Changing the order in which you post makes that more difficult, and
makes it less likely that we'll bother to read whatever you write.
Insisting on doing so repeatedly is rude.
 
J

Jorgen Grahn

I am a student taking a machine structures class in a university, which
includes learning C. I am looking for a good freeware or shareware
compiler which can be used in a "C only" mode.

This is the 21st century -- you are more likely to find good Free Software
than shareware or "freeware" these days. GCC and its derivates come to
mind:

http://en.wikipedia.org/wiki/GNU_Compiler_Collection
C++ isn't allowed in
assignments, and I would like the compiler to check for C syntax
instead of C++ syntax.

You need to look into which flags you pass to the compiler -- not only to
make sure you're not using C++, but also to enforce modern type checking,
warnings for stupid beginner's mistakes, to disable compiler-specific
extensions to the language, and to choose the C89 or C99 standard. For gcc,
a good starting point is

gcc -W -Wall -pedantic -std=c89
or
gcc -W -Wall -pedantic -std=c99

This applies to gcc and many or most other compilers.

/Jorgen
 
K

Keith Thompson

Jorgen Grahn said:
You need to look into which flags you pass to the compiler -- not only to
make sure you're not using C++, but also to enforce modern type checking,
warnings for stupid beginner's mistakes, to disable compiler-specific
extensions to the language, and to choose the C89 or C99 standard. For gcc,
a good starting point is

gcc -W -Wall -pedantic -std=c89
or
gcc -W -Wall -pedantic -std=c99

The latter doesn't entirely conform to the C99 standard;
it might or might not be close enough for your purposes.
See <http://gcc.gnu.org/c99status.html>.
 
D

Dave Vandervies

Sorry, but I insist on "top posting". I personally find it annoying to have
to scroll through a post to read the responce when I have been following the
conversation.

And most of the people reading here find it annoying to see an entire,
untrimmed, quoted post at the end of your post as the only context for
your comments.

If you really want to annoy us, none of us can stop you, but you can
expect a lot of us to ignore you.


dave
 
K

Kenny McCormack

And most of the people reading here find it annoying to see an entire,
untrimmed, quoted post at the end of your post as the only context for
your comments.

If you really want to annoy us, none of us can stop you, but you can
expect a lot of us to ignore you.

And you'll be the better for it. Think of it as self-killfiling.
 
A

Andrew Gentile

Jacob,
I just noticed your post. I have been using your compiler for
about a year. Excellent job. I have recommended it to many friends.
Thanks.

Andrew
 
N

napi

H. said:
I am a student taking a machine structures class in a university, which
includes learning C. I am looking for a good freeware or shareware
compiler which can be used in a "C only" mode. C++ isn't allowed in
assignments, and I would like the compiler to check for C syntax
instead of C++ syntax. Besides that, ease of use for a beginner and
basic debugging capabilities are important.

Suggestions are welcome.

Hi:

You can try AMPC (Axiomatic Multi-Platform C) compiler which supports
ANSI C (1989). It generates Java Bytecode which makes the executables
platform-independent. Check it out here: http://www.axiomsol.com

Have fun.

Napi
 
F

Flash Gordon

napi wrote, On 22/01/07 04:12:
Hi:

You can try AMPC (Axiomatic Multi-Platform C) compiler which supports
ANSI C (1989).

No it does not. According to your web site "AMPC covers a very large
subset of ANSI C (1989)." A large subset is *not* the language defined
by the standard, the language defined by the language is *all* of the
language defined by the standard. So if the OP finds that for his course
he is required to use feature X defined by the standard that you do not
currently support do you guarantee to add it to your compiler fast
enough not to cause him problems?
> It generates Java Bytecode which makes the executables
platform-independent. Check it out here: http://www.axiomsol.com

It is an interesting project, but I would not recommend it for people on
a course unless the course specifies it since you never know when you
might hit things it does not implement. At least with other compilers
you know that it is only bugs in the C89 implementation rather than
having not fully implemented C.
 
K

Kenny McCormack

napi wrote, On 22/01/07 04:12:

No it does not. According to your web site "AMPC covers a very large
subset of ANSI C (1989)." A large subset is *not* the language defined

It *could* be (noting that "could" is a word frequently used in this ng
as if it meant "is")

Hint: In mathematics, every set is a subset of itself. I.e., the set
itself can be referred to as a subset.
 
C

CBFalconer

Serve said:
Wow, is there a reason that this is *still* not finished?

Partially because gcc depends on local libraries, which are not
automatically updated, but belong to the individual system. I
believe most things that can be completely handled within the
compiler have been dealt with.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 
K

Keith Thompson

CBFalconer said:
Partially because gcc depends on local libraries, which are not
automatically updated, but belong to the individual system. I
believe most things that can be completely handled within the
compiler have been dealt with.

(This is about a specific compiler, but I claim it's topical because
it's also about the status of the C99 standard.)

Most, but not all. The items that, as far as I can tell, still
require compiler work are:

variable-length arrays
listed as "Broken"
complex (and imaginary) support in <complex.h>
This isn't listed as a library issue; I don't know why.
extended identifiers
Missing
extended integer types in <stdint.h>
Listed as Missing
I'm not sure what this one means. C99 allows, but does not
require, extended integer types. See C99 6.2.5p4. I'm not aware
that gcc provides any extended integer types -- but if it does,
there might be a requirement for <stdint.h> to use some of them.
IEC 60559 (also known as IEC 559 or IEEE arithmetic) support
Broken
inline functions
Broken
additional predefined macro names
Missing
I don't know what this refers to; gcc 4.1.1 seems to support all the
names specified in C99 6.10.8. See below for more information.
standard pragmas
Missing
I haven't looked into this.

Here's a program that shows the values of all the required and
optional predefined macros from 6.10.8:

#include <stdio.h>
int main(void)
{

#ifdef __DATE__
puts("__DATE__ = \"" __DATE__ "\"");
#else
printf("__DATE__ is not defined");
#endif

#ifdef __FILE__
puts("__FILE__ = \"" __FILE__ "\"");
#else
printf("__FILE__ is not defined");
#endif

#ifdef __LINE__
printf("__LINE__ = %d\n", (int)__LINE__);
#else
printf("__LINE__ is not defined");
#endif

#ifdef __STDC__
printf("__STDC__ = %d\n", (int)__STDC__);
#else
printf("__STDC__ is not defined");
#endif

#ifdef __STDC_HOSTED__
printf("__STDC_HOSTED__ = %d\n", (int)__STDC_HOSTED__);
#else
printf("__STDC_HOSTED__ is not defined");
#endif

#ifdef __STDC_VERSION__
printf("__STDC_VERSION__ = %ld\n", (long)__STDC_VERSION__);
#else
printf("__STDC_VERSION__ is not defined");
#endif

#ifdef __TIME__
puts("__TIME__ = \"" __TIME__ "\"");
#else
printf("__TIME__ is not defined");
#endif

#ifdef __STDC_IEC_559__
printf("__STDC_IEC_559__ = %d\n", (int)__STDC_IEC_559__);
#else
printf("__STDC_IEC_559__ is not defined");
#endif

#ifdef __STDC_IEC_559_COMPLEX__
printf("__STDC_IEC_559_COMPLEX__ = %d\n", (int)__STDC_IEC_559_COMPLEX__);
#else
printf("__STDC_IEC_559_COMPLEX__ is not defined");
#endif

#ifdef __STDC_ISO_10646__
printf("__STDC_ISO_10646__ = %ld\n", (long)__STDC_ISO_10646__);
#else
printf("__STDC_ISO_10646__ is not defined");
#endif

return 0;
}

And here's the output under gcc 4.1.1:

__DATE__ = "Jan 22 2007"
__FILE__ = "macros.c"
__LINE__ = 18
__STDC__ = 1
__STDC_HOSTED__ = 1
__STDC_VERSION__ = 199901
__TIME__ = "14:35:02"
__STDC_IEC_559__ = 1
__STDC_IEC_559_COMPLEX__ = 1
__STDC_ISO_10646__ = 200009

Possibly the web page doesn't reflect the latest release, and/or
perhaps some of the macro values don't quite reflect reality.
 
J

jacob navia

Andrew Gentile a écrit :
Jacob,
I just noticed your post. I have been using your compiler for
about a year. Excellent job. I have recommended it to many friends.
Thanks.

Andrew

Thanks you for this. Nice to see my work is good for someone!

jacob
 
J

Jorgen Grahn

[long snip]
Possibly the web page doesn't reflect the latest release, and/or
perhaps some of the macro values don't quite reflect reality.

They have, oddly enough, one general list and one per major release. I
surely hope those ones are correct, e.g.
http://gcc.gnu.org/gcc-4.1/c99status.html

More on topic: maybe compiler vendors should add options to enable c99
*except* the parts they have enabled but not gotten right? For example:

-std=cdecember98

Only partly joking. There are C99 additions I want to use, but I don't want
to accidentally make myself dependent on compiler-specific features in some
other area.

/Jorgen
 
S

Stephen Sprunk

Serve Laurijssen said:
that is only true if platform specific extensions could be compared to
driving through red light. platform specific extensions *are* allowed
so it doesnt make anybody a bad programmer when they use them.

I know a good programmer who uses gcc's extensions a lot. Is gcc bad
for introducing the features or the programmer or nobody?

Not at all. However, if GCC proponents came here and told people to use
their non-standard extensions without identifying them as such, they'd
be smacked down just like Mr. Navia is (on a regular basis).

The GCC people stick to their own newsgroups. On the rare occasions GCC
extensions are proposed by regulars here, they're clearly noted as such.
Mr. Navia has shown absolutely no inclination to follow accepted
netiquette or topicality, despite having been asked several dozen times.
_That_ is why he is disliked, not his extensions. He's welcome to
discuss them all he likes over in the newsgroup for LCC.

S
 
N

napi

napi wrote, On 22/01/07 04:12:
No it does not. According to your web site "AMPC covers a very large
subset of ANSI C (1989)." A large subset is *not* the language defined
by the standard, the language defined by the language is *all* of the
language defined by the standard. So if the OP finds that for his course
he is required to use feature X defined by the standard that you do not
currently support do you guarantee to add it to your compiler fast
enough not to cause him problems?

You are right. But, the only ANSI C (1989) library functions that AMPC
does
not support are longjmp(), setjmp(), signal(), and raise(). It
supports all others.

Napi
 
D

Dave Vandervies

You are right. But, the only ANSI C (1989) library functions that AMPC
does
not support are longjmp(), setjmp(),

setjmp is a macro, not a function. It seems to me that it shouldn't be
too hard to invoke some compiler magic to compile setjmp/longjmp as a
fairly thin wrapper around try/throw.
signal(), and raise().

Why not those? They should be some of the easiest to implement,
especially since there's no requirement that an implementation be able
to actually generate signals asynchronously.

Here's a first pass at it to get you started.
(Not compiled or tested. The usual disclaimers apply, and then some.)
--------signal.h
#ifndef __SIGNAL_H
#define __SIGNAL_H

/*N869 7.14#1*/
typedef int sig_atomic_t;

/*Make some of the definitions a little bit easier to write*/
typedef void (*__sighandler_t)(int);

/*N869 7.14#3*/
extern __sighandler_t __sig_dfl;
#define SIG_DFL __sig_dfl;
extern __sighandler_t __sig_err;
#define SIG_ERR __sig_err;
extern __sighandler_t __sig_ign;
#define SIG_IGN __sig_ign;

#define SIGABRT 1
#define SIGFPE 2
#define SIGILL 3
#define SIGINT 4
#define SIGSEGV 5
#define SIGTERM 6
#define __MAX_SIGNAL 7

/*N869 7.14.1.1*/
__sighandler_t signal(int,__sighandler_t);

/*N869 7.14.2.1*/
int raise(int);

#endif /*__SIGNAL_H #include guard*/
--------

--------signal_implementation.c
#include <signal.h>
#include <stdlib.h>

void __sig_dfl(int sig)
{
if(sig==SIGTERM || sig==SIGINT)
{
/*termination request or interrupt are typically
not fatal errors
*/
exit(EXIT_SUCCESS);
}
else
{
/*All other signals indicate some fatal error condition*/
exit(EXIT_FAILURE);
}
}

void __sig_err(int sig)
{
/*We should never get here*/
abort();
}

void __sig_ign(int sig)
{
/*do nothing*/
}

static __sighandler_t handlers[]=
{
NULL, /*dummy*/
__sig_dfl, /*SIGABRT*/
__sig_dfl, /*SIGFPE*/
__sig_dfl, /*SIGILL*/
__sig_dfl, /*SIGINT*/
__sig_dfl, /*SIGSEGV*/
__sig_dfl /*SIGTERM*/
};

__sighandler_t signal(int sig,__sighandler_t newhandler)
{
__sighandler_t old_handler=handlers[sig];
handlers[sig]=newhandler;
return old_handler;
}

int raise(int sig)
{
handlers[sig]();
}
--------


Question for the language lawyers: Is this a correct C program?
--------
#include <signal.h>
int main(void)
{
SIG_DFL(SIGTERM);
return 0;
}
--------
I suspect not, but I wouldn't be willing to defend any answer without
further study.


dave
 

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,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top