官术网_书友最值得收藏!

Summary

In this chapter, we revisited some of the important features of the C programming language. We tried to go further and show the design aspects of these features and the concepts behind them. Of course, the proper use of a feature requires a deeper insight into the different aspects of that feature. As part of this chapter, we discussed the following:

  • We talked about the C preprocessing phase and how various directives can influence the preprocessor to act differently or generate a specific C code for us.
  • Macros and the macro expansion mechanism allow us to generate C code before passing the translation unit to the compilation phase.
  • Conditional directives allow us to alter the preprocessed code based on certain conditions and allow us to have different code for different situations.
  • We also looked at variable pointers, and how they are employed in C.
  • We introduced generic pointers and how we can have a function that accepts any kind of pointer.
  • We discussed some issues such as segmentation faults and dangling pointers to show a few disastrous situations that can arise from misusing pointers.
  • Functions were discussed next, and we reviewed their syntax.
  • We explored functions' design aspects and how they contribute to a nicely shaped procedural C program.
  • We also explained the function call mechanism and how arguments are passed to a function using stack frames.
  • Function pointers were explored in this chapter. The powerful syntax of function pointers allows us to store logics in variable-like entities and use them later. They are, in fact, the fundamental mechanism that every single program uses today to be loaded and operate.
  • Structures together with function pointers gave rise to encapsulation in C. We speak more about this in the third part of the book, Object Orientation.
  • We tried to explain the design aspects of structures and their effect on the way we design programs in C.
  • We also discussed the memory layout of structure variables and how they are placed inside memory to maximize CPU utilization.
  • Nested structures were also discussed. We also took a look inside the complex structure variables and discussed how their memory layout should look.
  • As the final section in this chapter, we talked about structure pointers.

The next chapter will be our first step in building a C project. The C compilation pipeline and linking mechanism will be discussed as part of the next chapter. Reading it thoroughly will be essential to continue with the book and proceed to further chapters.

主站蜘蛛池模板: 蓝田县| 梅州市| 米易县| 青浦区| 余干县| 金门县| 滨州市| 赤壁市| 莱芜市| 崇义县| 五莲县| 鄯善县| 左贡县| 修水县| 缙云县| 嘉黎县| 奉化市| 宕昌县| 和田县| 若尔盖县| 盐边县| 仙居县| 罗定市| 永济市| 临邑县| 古交市| 丰都县| 左贡县| 隆昌县| 稷山县| 寿阳县| 舟曲县| 西安市| 翁源县| 周至县| 麻栗坡县| 通榆县| 葵青区| 土默特左旗| 海丰县| 高淳县|