How to Understand GCC

Understanding GCC is not something that can be done quickly. Even for experienced programmers, the source code is extremely hard to comprehend (not because it's necessarily intellectually difficult, but rather because the source code is so dense and, at times, vague). Nonetheless, here are some tips:


 * 1) Read about GCC. A lot can be learned about what GCC is trying to achieve by reading articles, books and websites. Whilst such information is hard to come by, and whilst a lot of it is out of date, it is vital if you want to get started, since it will give you the theoretical context you need in order to begin to understand what is going on. How are you going to understand GCC if you don't even know what a tree in GCC is, for example?
 * 2) Don't trust the comments. Whilst GCC is heavily commented, many of the comments are objectively wrong. Even those comments that aren't wrong are sometimes badly explained. A lot of comments have become outdated as features have been added and removed, and many of the comments were written by people whose first language is not English. Read the code first, understanding it line by line, and then use the comments to confirm your understanding.
 * 3) Don't reinvent the wheel. Chances are, if you're looking to add or alter some piece of functionality, someone has already done 80% of the work for you somewhere else in the source code. Look at how they did it and then re-write what they did to fit your needs.
 * 4) Do a little every day. You can only learn so much in a day before fatigue starts to set in. And as we all know, when we're learning something new, some of the most helpful epiphanies occur in the shower, and most people only have one shower per day. A little every day equals more days, which equals more showers and thus more epiphanies. Duh.