Makes it sense to get a copy of the ANSI standard documents?

  • Thread starter Wolfgang Draxinger
  • Start date
W

Wolfgang Draxinger

As already noted a few months ago I'm working on a language, that
is intended to be compiled into C as an intermediary.

ATM I'm working with the latest publically avaliable draft of C99
avaliable from open-std.org. However I was considering to obtain
a copy of the real thing, but I wonder if it worth it. Mainly
I'm interested in _generating_ standard conforming code. Is it
worth it? Also I'd like to know, where to get a copy of the old
C90 standard, I can't find it on the ANSI website.

And then there's the question which version to target. C90 would
be the most portable for sure, OTOH any program compiled with my
compiler will have been written after 2006 so I can be sure to
have a final C stage that knows at least some C99. Some C99
features would be nice. So what is really safe to be used
_today_?

Wolfgang Draxinger
 
R

robertwessel2

As already noted a few months ago I'm working on a language, that
is intended to be compiled into C as an intermediary.

ATM I'm working with the latest publically avaliable draft of C99
avaliable from open-std.org. However I was considering to obtain
a copy of the real thing, but I wonder if it worth it. Mainly
I'm interested in _generating_ standard conforming code. Is it
worth it? Also I'd like to know, where to get a copy of the old
C90 standard, I can't find it on the ANSI website.

And then there's the question which version to target. C90 would
be the most portable for sure, OTOH any program compiled with my
compiler will have been written after 2006 so I can be sure to
have a final C stage that knows at least some C99. Some C99
features would be nice. So what is really safe to be used
_today_?


It certainly can't hurt to have a copy of the standard, at least it
gives you a baseline which is fairly well supported. See:

http://clc-wiki.net/wiki/The_C_Standard

For a list of ways to get the C89/90 standards. The commonly used
draft is pretty darn close to the final standard, and is free (unlike
the real dead tree version of c89).

While the real C99 standard is available for a reasonable price, and
even in electronic form, unfortunately c99 is very poorly supported in
the world.

While probably heresy in this group, targeting C++ instead of C as an
intermediate language has become very common, the ability to define
types and overloaded operators is very nice in this application. And C
++ is infinitely better supported than C99 (although not C89).
 
J

jacob navia

While probably heresy in this group, targeting C++ instead of C as an
intermediate language has become very common, the ability to define
types and overloaded operators is very nice in this application. And C
++ is infinitely better supported than C99 (although not C89).

This is pure nonsense.

Nobody is going to WRITE that code nor it is going to read it!
You can make your code call
add128(a,b)

with the SAME effort that you write
a+b

Operator overloading is useful for PEOPLE writing code.

When a machine writes the code nobody would care, and you
would have to cope with C++.

Did you know that code trhat compiled without a hitch in
IBM C++ xlc 8.0 will no longer compile in IBM xlc 9.0?

And code that compiled without any problems in gcc 3.4
will no longer compile in gcc 4.0?

C++ is a language that *maybe* is useful for people
writing code. For an automatic generator is sheer nonsense.

The more lower level you go, the better.
 
I

Ioannis Vranos

Wolfgang said:
As already noted a few months ago I'm working on a language, that
is intended to be compiled into C as an intermediary.

ATM I'm working with the latest publically avaliable draft of C99
avaliable from open-std.org. However I was considering to obtain
a copy of the real thing, but I wonder if it worth it. Mainly
I'm interested in _generating_ standard conforming code. Is it
worth it? Also I'd like to know, where to get a copy of the old
C90 standard, I can't find it on the ANSI website.


I think what you need is C95, not C90. C95 is C90 with some bugs fixed +
3 new headers, <wchar.h>, <iso646.h>, <wctype.h>.


If you can't find a copy of C95/C90, you can buy the book "The C
Programming Language" 2nd Edition by Brian Kernighan, Dennis Ritchie
(the creator of C) which towards the end has an "Appendix A: Reference
manual".

The first part of its introduction is the following:

"A1. Introduction

This manual describes the C language specified by the draft
submitted to ANSI on 31 October 1988, for approval as "American National
Standard for Information Systems-Programming Language C, X3.159-1989".
The manual is an interpretation of the proposed standard, not the
Standard itself, although care has been taken to make it a reliable
guide to the language".
 
R

Richard

Ioannis Vranos said:
I think what you need is C95, not C90. C95 is C90 with some bugs fixed +
3 new headers, <wchar.h>, <iso646.h>, <wctype.h>.


If you can't find a copy of C95/C90, you can buy the book "The C
Programming Language" 2nd Edition by Brian Kernighan, Dennis Ritchie
(the creator of C) which towards the end has an "Appendix A: Reference
manual".

The first part of its introduction is the following:

"A1. Introduction

This manual describes the C language specified by the draft
submitted to ANSI on 31 October 1988, for approval as "American National
Standard for Information Systems-Programming Language C, X3.159-1989".
The manual is an interpretation of the proposed standard, not the
Standard itself, although care has been taken to make it a reliable
guide to the language".

With all due respect, you do not even know about sequence points and
undefined behaviour. Do you really think you are qualified to tell a
compiler writer what versions of the standard he should be using?

K&R 2 is not a standard in the true "standard" sense.
 
I

Ioannis Vranos

Richard said:
With all due respect, you do not even know about sequence points and
undefined behaviour.


I know about undefined behaviour. I do not know about sequence points,
because all the books I have read regarding C and C++ didn't mention
them (I am in the application programming area, not compiler creation).
Of course, I'll check the standards to find out what sequence points are.

Do you really think you are qualified to tell a
compiler writer what versions of the standard he should be using?

I think I have a down to earth knowledge about the various C and C++
standards and their differences.

C95 is essentially the C standard that the most popular C compilers
support (and is the "C subset" of C++98/C++03).


Given that C95, is C90 fixed and improved, and not a major evolution
like C99, I think if one is to by a C standard that is not C99, he
should pick C95.
 
R

richard kenny twink

Wolfgang said:
As already noted a few months ago I'm working on a language, that
is intended to be compiled into C as an intermediary.

ATM I'm working with the latest publically avaliable draft of C99
avaliable from open-std.org. However I was considering to obtain
a copy of the real thing, but I wonder if it worth it. Mainly
I'm interested in generating standard conforming code. Is it
worth it? Also I'd like to know, where to get a copy of the old
C90 standard, I can't find it on the ANSI website.

Here a draft of the C90 standard:
http://flash-gordon.me.uk/ansi.c.txt

You can purchase the current standard (INCITS/ISO/IEC 9899-1999
(R2005)) for $30, but the former standard is hard to come by for a
reasonable price.
And then there's the question which version to target. C90 would
be the most portable for sure, OTOH any program compiled with my
compiler will have been written after 2006 so I can be sure to
have a final C stage that knows at least some C99. Some C99
features would be nice. So what is really safe to be used
_today_?

If you use a fairly ubiquitous compiler like GCC, then you could safely
use the C99 features available in GCC.

HTH
 
B

Bartc

jacob navia said:
This is pure nonsense.

Nobody is going to WRITE that code nor it is going to read it!
You can make your code call
add128(a,b)

with the SAME effort that you write
a+b

I agree almost entirely with this.

But, the code generator has to /know/ that add128 is needed and not add64
etc. So if no proper type analysis has been done, and the language has types
only fully supported in C++, then maybe a C++ target can start to make
sense.

It sounds like the OP has more sensibly chosen C as a target however.
The more lower level you go, the better.

Well, not too low a level. A C intermediate representation seems popular,
although generating actual /source/ (and being bothered about syntax and
name spaces and such matters that are irrelevant to the original language)
has it's own problems.
 
R

robertwessel2

This is pure nonsense.

Nobody is going to WRITE that code nor it is going to read it!
You can make your code call
        add128(a,b)

with the SAME effort that you write
        a+b

Operator overloading is useful for PEOPLE writing code.

When a machine writes the code nobody would care, and you
would have to cope with C++.


We'll have to disagree on this, but for just one example, your
approach requires the front end compiler to explicitly manage
temporaries when evaluating expressions, which is work that can be put
off to the C++ back end. The length of a particular function
invocation is not much of an issue for q code generator; but using
higher level constructs in the back end can often allow simpler code
to be emitted. Now you may *want* to do that in some cases to
maintain full control over how expression is evaluated, but C++ gives
you the choice.

Did you know that code trhat compiled without a hitch in
IBM C++ xlc 8.0 will no longer compile in IBM xlc 9.0?

And code that compiled without any problems in gcc 3.4
will no longer compile in gcc 4.0?


And there have never been release dependent glitches in C compilers?

That being said, using C as a back end will likely give you better
portability.

C++ is a language that *maybe* is useful for people
writing code. For an automatic generator is sheer nonsense.

The more lower level you go, the better.


Sometimes yes, sometimes no.
 
I

Ioannis Vranos

jacob said:
C++ is a language that *maybe* is useful for people
writing code. For an automatic generator is sheer nonsense.

The more lower level you go, the better.


Just for informative purposes, the "assembly language" of CLI
(.NET/Mono) CIL (sometimes mentioned ILASM), is object oriented.


MS has a book about "ILASM". Check Amazon.
 
J

jacob navia

Ioannis said:
Just for informative purposes, the "assembly language" of CLI
(.NET/Mono) CIL (sometimes mentioned ILASM), is object oriented.


MS has a book about "ILASM". Check Amazon.

I know that...

Did you know that they have written a complete new shell in C#
(that compiles to that abomination called ILASM)

If you time

dir /s *.* | grep NOTFOUND

using the CMD shell (C based) it takes two/three seconds
Using the new shell it takes around 4.5 Minutes.

But obviously you wait with joy!

IT IS OBJECT ORIENTED!

Yes. THIS is PROGRESS.


ILASM is an apparently low level object oriented assembly language.
It needs to be translated into the real assemble however. I know,
those are mere "implementation details".
 
I

Ioannis Vranos

jacob said:
I know that...

Did you know that they have written a complete new shell in C#
(that compiles to that abomination called ILASM)

If you time

dir /s *.* | grep NOTFOUND

using the CMD shell (C based) it takes two/three seconds
Using the new shell it takes around 4.5 Minutes.

But obviously you wait with joy!

IT IS OBJECT ORIENTED!

Yes. THIS is PROGRESS.


ILASM is an apparently low level object oriented assembly language.
It needs to be translated into the real assemble however. I know,
those are mere "implementation details".



All eventually end up to machine code. My point is, given that C++
exists, is a systems programming language, and its standard C++98/03 is
supported by all popular C++ compilers, it can be used as an
intermediate language too, and not C only.

For example one can use C++ high level facilities.
 
G

geese786

it makes sense to do anything opposite of what heathfield says.

don't read his book its total garbage.

he has no qualification in c

ask navia
 
S

santosh

Ioannis said:
All eventually end up to machine code. My point is, given that C++
exists, is a systems programming language, and its standard C++98/03
is supported by all popular C++ compilers, it can be used as an
intermediate language too, and not C only.

For example one can use C++ high level facilities.

Yes, but C++ has absolutely nothing to do with C# or .NET or ILASM.
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top