When compiling multiple source code files in the C or C + + language, if A.C uses the functions in the B.C file, you need to use extern to pre-define the functions in B.C in the A.c file, and extern is to tell the compiler the function name, the number of arguments, the parameter type, and the return value type. This information is sufficient for compiling A.C into A.O. When the A.O,B.O is linked to an executable file or library, the compiler then looks for a specific implementation of the function in B.O. That is, extern only works in the compile phase. In addition, you can also use B.h to define the functions in B.C, and then include B.h files in A.C. You can omit the extern keyword for some c/+ + compilers.
Consolidating individual files to form Linux drives, writing makefile files is the most critical step. If the Linux driver has only one source code file, the value of the OBJ-M variable can be the same as the source code file. If the Linux driver contains multiple files, you will need to use Module-y to specify all the target files. You cannot specify only the referenced target file.
In some cases, there may be exceptions to the program, and Linux drivers may not be able to unload properly. Dynamic Linux modules can be uninstalled from memory by restarting the emulator or the Development Board. But if you have to restart the machine every time you can't unload the drive, it's too much trouble. Of course, not all of them can be solved. Only the initialization function of the crash or unload function is blocked to a certain way to solve.
Android Deep Explore eighth chapter