C Project Decomposition

xiaoxiao2021-03-06  105

First, this is exactly my personal opinion, you can (maybe you really will?) Do other ways. This will touch the problem of coding style, and everyone has never stopped the debate on this issue. Here I just give my own favorite practices (while giving this reason):

i) Do not point to multiple source files with a header file (exception: the HEADER file for the package). The way to define a source code file is more efficient and easier to find. Otherwise, changing the structure of a source file (and its header file) must recompile several files.

II) If you can, you can use more than one header file to point to the same source code file. Sometimes the function prototype, type definition, and so on, which cannot be invoked, and it is very useful from their C source file files. Using a Header file to install public symbols, use another private symbol that if you change the internal structure of this source file, you can just recompile it without having to recompile other source files that use its public header file. .

III) Do not repeat the definition information in multiple header files. If necessary, in one of the header files #include one, but do not repeat the same Header information twice. The reason is if you change this information later, you only need to change it once, do not search and change another repetition.

IV) In each source file, #include states all Header files that declare the symbols in the source file file. In this way, the contradictions you make in some functions in the source file and the Header file can be discovered by the compiler.

转载请注明原文地址:https://www.9cbs.com/read-104234.html

New Post(0)