views:

1267

answers:

7

I'm looking for a good book or website on how C++ works under the hood. Some topics might be virtual function lookup tables, function name mangling, class/struct relationship, etc.

Even better, something that covers other languages as well (I'd love to know more about Perl's internals)

Thanks!

+8  A: 
Martin Beckett
I read this years ago, when it was new. But it describes the pre-Standard C++. I don't have a copy handy, is it still a reasonable choice for describing details, given that CFront was still an active option when it came out?
Don Wakefield
It's still good for the why rather than the how.The how is compiler/os specific anyway (in theory if not in practice)
Martin Beckett
+11  A: 

Those sorts of internals you list are implementation dependent. It's one of the things that makes C/C++ different than other languages is there's quite a bit of latitude for the implementer.

The best book on C++ for me is Stroustrup's "Design and Evolution of C++" - not quite what you're asking but covers why C++ is the way that it is. That book is very old.

Tony Lee
+17  A: 

I haven't read it, but you may want to consider Inside the C++ Object Model by Stan Lippman

James Curran
I *have* read it and it provides a great look at what typically happens under the covers. Be aware that the implementation described in this book does not necessarily match any particular compiler but it gives the reader a good idea about what a C++ implementation must provide.
jwfearn
I agree, read this and Design and Evolution and you will have a great understanding of how and why C++ works.
Matt Price
Absolutely the best!
Jeff Kotula
A: 

SGI produced a book called "C++ Language System Overview" which had several articles on the physical implementation of the language. Of particular interest was an article by Stroustrup on how multiple inheritance and casting is carried out. It also had an overview of iostreams, and templates. It has a lot more detail than the ARM, but obviously not as much breadth. I'm not sure if it's available at SGI (soft/hardcopy), but you could google, and see if someone has a copy.

Dan Hewett
+4  A: 

Stroustrup wrote a book in the early days of C++ called "The Design and Evolution of C++". It's a bit dated now, but I consulted with it a lot when I was working on Metrowerks' C++ compiler to understand some of the key ideas behind the language.

If you want to understand a modern C++ implementation, including vtable layout, look at the ABI description for Itanium (IA64). This was worked on by Intel and the compiler community to ensure that different C++ implementations for that architecture would be compatible.

Ben Combee
+1  A: 

Try the InformIT C++ reference guide, see here. It's free.

TonJ
A: 

While not exactly related to internals, the "Effective Serices" (Effective C++, etc.) gives good insight to some of the quirkiness of C++.