Lindon wrote:
Until now I've been programming straight console apps, and all I've
been doing to compile is a simple 'gcc file1.cpp file2.cpp ....'.
What more is there to know about the compiler? I'd like to know
exactly what happens during each step. Is the compilation of dll's
(and corresponding libs on *nix) possible with only the compiler and
no platform specifc libraries (like windows.h)? What am I missing out
on?
thanks,
lin
I suggest you search the web or get some books on compiler theory.
Compiler theory is to vast a subject to describe in a single post.
Many universities offer year-long courses on the subject.
Here is a brief overview:
1. A source file is processed by the "preprocess or" which handles
the #if, #define and etc. statements (& directives). The output
is a "translatio n unit". The Preprocessor may also extract out
comments.
2. The translation unit is then parsed into tokens.
(See subject of "lexical analysis" using your favorite search
engine).
3. The tokens are then processed according to a "grammar", which
is a set of rules for the language.
4. The parser may create an interim or assembly language. This
interim language is then passed to another processor which
translates the language into an "object" format. The object
format contains the binary machine code (executable code)
usually in a relative format along with some symbolic info.
5. A linking or binding step is performed next. The linker
combines these object files, and resolves undefined
references and produces an executable program.
6. Libraries are created by coagulating (coercing?), collecting
or combining many object files into a single file. The
librarian may resolve any undefined references.
The above steps may be combined into one step or not at all.
Dynamic Link Libraries and Shared Libraries _are_ platform
specific. These are units of code that are loaded on demand
during run-time by the operating system as opposed to
static libraries which are loaded during the build process.
Compiler theory and shared / dynamic libraries are not
discussed (in depth) in this newsgroup. For further
information, search newsgroups about your compiler or
operating system and also search the web.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book