RFC: How a C/C++ Compiler works

RFC: How a C/C++ Compiler works

Post by Jon Hein » Thu, 31 Jul 2003 07:57:05



I am posting here in followup to a thread at my workplace. Some of us
were discussing how C/C++ compilers work, and we were hoping to get
some good references. By "good", I mean we'd like to avoid the
academic tombs ( e.g.: Aho, Grune, etc. ) that are excellent
theoretical references, but don't necessarily help experienced
programmers do their job better.

I would like to believe that meaty references exist that are < 1000
pages, but still have depth, and are targetted towards professionals
who would benefit from a 3-mile view of a specific compiler
architectures. Perhaps the GNU compiler has a doc section that I
haven't seen before, or someone knows of a great out-of-print
reference, or there is a VC++ fan page. ;)

Please respond with links, authors, articles... if you feel you have a
good understanding of C/C++ compilers and want to help other
professionals who don't necessarily get to write compilers, but want
to learn more in order to improve their knowledge base.

Sincerely,
Jon Heiner

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

 
 
 

RFC: How a C/C++ Compiler works

Post by Ben Hutching » Fri, 01 Aug 2003 09:12:36



<snip>
Quote:> I would like to believe that meaty references exist that are < 1000
> pages, but still have depth, and are targetted towards professionals
> who would benefit from a 3-mile view of a specific compiler
> architectures. Perhaps the GNU compiler has a doc section that I
> haven't seen before, or someone knows of a great out-of-print
> reference, or there is a VC++ fan page. ;)

<snip>

There is a GCC Internals Manual at <http://gcc.gnu.org/onlinedocs/gccint/>
but it seems to be intended for people who wish to modify the compiler
rather than those who are just curious, and much of the explanation is
"this is implemented in foo.c and bar.c".

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

 
 
 

RFC: How a C/C++ Compiler works

Post by Thomas Man » Fri, 01 Aug 2003 21:37:58


Jon Heiner schrieb:

 > I am posting here in followup to a thread at my workplace. Some of us
 > were discussing how C/C++ compilers work, and we were hoping to get
 > some good references. By "good", I mean we'd like to avoid the
 > academic tombs ( e.g.: Aho, Grune, etc. ) that are excellent
 > theoretical references, but don't necessarily help experienced
 > programmers do their job better.
 >
 > I would like to believe that meaty references exist that are < 1000
 > pages, but still have depth, and are targetted towards professionals
 > who would benefit from a 3-mile view of a specific compiler
 > architectures. Perhaps the GNU compiler has a doc section that I
 > haven't seen before, or someone knows of a great out-of-print
 > reference, or there is a VC++ fan page. ;)
 >
 > Please respond with links, authors, articles... if you feel you have a
 > good understanding of C/C++ compilers and want to help other
 > professionals who don't necessarily get to write compilers, but want
 > to learn more in order to improve their knowledge base.
 >
 > Sincerely,
 > Jon Heiner
 >

Try "Inside the C++ Object Model", by STanley Lippman.

regards,

Thomas

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

 
 
 

RFC: How a C/C++ Compiler works

Post by Yuval Hofs » Sat, 02 Aug 2003 03:52:34


Try:

Inside the C++ Object Model
by Stanley B. Lippman
ISBN: 0201834545

This is not a classic 'compiler design' book.
It does not include all the theoretical issues usually described in
these kind of books - scanning and parsing (lexing and yaccing), code
generation etc.

This one focuses on the semantics of the C++ object model - the way
compilers 'see' and analyze your C++ code.
Unlike other C++ related books, this one deals with how C++ features
can be implemented, rather then how they can be used.

Hope that helps,
Yuval.

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

 
 
 

RFC: How a C/C++ Compiler works

Post by Jon Hein » Sat, 02 Aug 2003 17:41:42


 > There is a GCC Internals Manual at <http://gcc.gnu.org/onlinedocs/gccint/>
 > but it seems to be intended for people who wish to modify the compiler
 > rather than those who are just curious, and much of the explanation is
 > "this is implemented in foo.c and bar.c".

This is actually quite useful. And for the appropriate audience. I
have no issues pulling down the gcc source and grokking it. I doubt
i'll understand everything, but this reference gives a good 3-mile
view along with insert points to jump into code. THANX!

Also, to the several people who have suggested the Lippman book. Thank
you. That was a title I hadn't noticed by Lippman. It is now at the
top of my reading list. And I like that it is compiler agnostic while
being language specific ( most compiler texts are the converse. )

As a followup for clarification, can anyone suggest additional
articles/references for people who's bread and butter is C++ but may
not yet be guru level. For example, i've found some nice info on
tuning pre-compiled headers, which has proved useful.

thanx for the suggestions,
Jon

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

 
 
 

RFC: How a C/C++ Compiler works

Post by Francis Glassboro » Sun, 03 Aug 2003 01:05:34




Quote:>This one focuses on the semantics of the C++ object model - the way
>compilers 'see' and analyze your C++ code.
>Unlike other C++ related books, this one deals with how C++ features
>can be implemented, rather then how they can be used.

To be accurate it deals with the way that a compiler (CFront) handled
C++. It is a way not 'the' way.

--
ACCU Spring Conference 2003 April 2-5
The Conference you should not have missed
ACCU Spring Conference 2004 Late April
Francis Glassborow      ACCU

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

 
 
 

RFC: How a C/C++ Compiler works

Post by Michiel Salte » Sun, 03 Aug 2003 13:32:04



> Try:

> Inside the C++ Object Model
> by Stanley B. Lippman
> ISBN: 0201834545

> This is not a classic 'compiler design' book.
> It does not include all the theoretical issues usually described in
> these kind of books - scanning and parsing (lexing and yaccing), code
> generation etc.

> This one focuses on the semantics of the C++ object model - the way
> compilers 'see' and analyze your C++ code.
> Unlike other C++ related books, this one deals with how C++ features
> can be implemented, rather then how they can be used.

The important word of the last sentence is "can". A better title
would have been "Inside_a_ C++ Object Model". There are more
models. The model presented is a reasonable one, though, and it
is close to many real-world compilers.

Regards,
--
Michiel Salters

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

 
 
 

1. How does a C++ compiler work?

I remember it will generate an object file, and then link the object file to
something in order to produce an executable file.  Right?  But I don't know
exactly how.  Would you people please kindly and briefly educate?  Thanks.
By
the way, what kind of tutorial should I read about this?  You know,
programming books usually don't tell you how a compiler works.

2. CONFERENCE: ENTERPRISE MANAGEMENT SUMMIT '94

3. NEED ON-LINE C++ COMPILER TO WORK ON LINE

4. WMI suppress menu

5. RFC: declaring initialized variables in C++

6. Zone Alarm Problem

7. Shippable C++ Objects (RFC)

8. Problems With File Transfer And Scripting

9. A RFC for YAAC++ ( yet another addition to C++ )

10. Can a C++ compiler behave like a C compiler and keep switching modes?

11. C++ functions in DLL's with different C++ compilers

12. ? Best Windows C++ Compiler? C++ Builder?