在整理笔记的时候肯定会从网上查找资料,每个知识点肯定都会碰到一篇帖子让自己感慨“哇,总结得好好,娓娓道来,该讲的都讲到了,却也不多一句废话”,每每到此刻都觉得自己整理的笔记就是一坨垃圾,用词不当,表述不清晰,上下文转接不流畅,有的重点落下没讲,废话说太多……可这就是成长必经的过程,如果不是整理这个知识点,就不会一板一眼、较真地去查阅好多资料,线上的博客、线下的书,随手 google 来的终究只是编码过程中的 code demo,而非知识,只有当你读了很多篇笔记,看过了很多风景,才能有足够的理解,才能通过已经掌握的,通过对比,认识到某一篇是够精彩的。
doit 我没能坚持下来就是因为错误的使用方式。每天罗列好多的内容,带来虚假的成就感;每天完成一些(大多是最容易的),看着任务打上对勾,被划掉,带来虚假的成就感。甚至为了“打对勾,划掉”写上已经完成的事项,写上不重要的、做不做并无关键区别、随手就能解决、非关键任务等等类似的内容。然后把上午、下午大块大块的完整时间用来处理这些个“自讨的”琐碎任务,以“划掉多少”等价“成就多少”。好脆弱的内心,好虚假的幻想!随着时间的积累(也就是半年),doit 列表中堆积了大量的待办事项,而且都是筛选之后需要花费一定时间、精力并且有意义的事情,积累的越多越是提醒着自己的失败。潜意识里回避真相,现实世界里就做出“不再使用这款工具”的决定。关键问题在于:
知道了预处理器(cpp)要读取头文件,那么报错“xxx.h:No such file or directory”就需要确认我们是不是指定了查找目录,或者核对我们指定的路径是否包含该头文件;同样的道理,链接器(ld)需要链接目标文件,和前者稍有不用的地方在于:头文件一般都写在源代码中,我们只需要指定头文件路径;而链接目标文件时,既需要我们指出目标文件所在的目录,同时还需要我们指定使用目标路径下的哪个文件。
To understand the behavior of C and C++ programs, you need to know about linkage. In an executing program, an identifier is represented by storage in memory that holds a variable or a compiled function body. Linkage describes this storage as it is seen by the linker. There are two types of linkage: internal linkage and external linkage.
Internal linkage means that storage is created to represent the identifier only for the file being compiled. Other files may use the same identifier name with internal linkage, or for a global variable, and no conflicts will be found by the linker – separate storage is created for each identifier. Internal linkage is specified by the keyword static in C and C++.
External linkage means that a single piece of storage is created to represent the identifier for all files being compiled. The storage is created once, and the linker must resolve all other references to that storage. Global variables and function names have external linkage. These are accessed from other files by declaring them with the keyword extern. Variables defined outside all functions (with the exception of const in C++) and function definitions default to external linkage. You can specifically force them to have internal linkage using the static keyword. You can explicitly state that an identifier has external linkage by defining it with the extern keyword. Defining a variable or function with extern is not necessary in C, but it is sometimes necessary for const in C++.
Automatic (local) variables exist only temporarily, on the stack, while a function is being called. The linker doesn’t know about automatic variables, and so these have no linkage.
跌跌撞撞,兜来绕去,终究还是在 C++ 这个圈子里。毕业时,因为身外事去选择工作单位,而工作单位决定了工作性质,决定了自己处在做软件的边缘,甚至一度成为网管。两年之后跳出陷阱时,背负着“过去的选择”走进了 C++ 的世界,因为一无所长,在诸多技术更迭交替的 IT 圈我像个刚入门的新人似的,只了解一点点 VC++。我没有从头来过的魄力,我也并不清楚 Java 是否更有前途,互联网是否更多辛苦。
在毕业刚好三年的边上,想着“就是 C++ 了”其实很愚蠢。通过做决定安慰自己“明智”,其实只是没得选择的妥协。此时此刻应该想的是“如何学好 C++”,更现实一点“掌握 C++ 的哪些内容,能找到更好的工作”。暂时确定的目标: