This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
请问DCL库中的DCL_resetPID和updatePID函数是static inline,使用过程中外部如果要做reset和updata怎么处理呢
Hi July,
‘static'定义了一个函数,该函数在标准中具有所谓的“内部链接”。它的基本意思是,除了定义它的translation unit之外,该函数不可用于任何其他translation unit。
所以a.c + dcl.h是一个单元,b.c + dcl.h是另一个。将static inline function放置在一个头文件中,相当于你告诉编译器去在每一个被用到的translation unit中define这个函数。包含 dcl.h 的 a.c 可以调用该函数,包含 dcl.h 的 b.c 也可以。但是您将在程序的可执行文件中对该静态内联函数有两个定义。 这并不会导致冲突,因为链接器知道哪个符号与哪个单元相关。 因此,当它在 a.c 中看到对内部链接函数的引用时,它会忽略该函数的任何定义,除了 a.c 中的定义。