Is extern keyword really necessary?

后端 未结 5 1797
鱼传尺愫
鱼传尺愫 2020-12-17 01:20
...
#include \"test1.h\"

int main(..)
{
    count << aaa <

aaa is defined in test1.h,and I didn\'t u

5条回答
  •  执念已碎
    2020-12-17 01:22

    In that case, extern is not necessary. Extern is needed when the symbol is declared in another compilation unit.

    When you use the #include preprocessing directive, the included file is copied out in place of the directive. In this case you don't need extern because the compiler already know aaa.

提交回复
热议问题