How to correctly use the extern keyword in C

后端 未结 10 2395
感情败类
感情败类 2020-11-22 08:11

My question is about when a function should be referenced with the extern keyword in C.

I am failing to see when this should be used in practice. As I

10条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 08:20

    If each file in your program is first compiled to an object file, then the object files are linked together, you need extern. It tells the compiler "This function exists, but the code for it is somewhere else. Don't panic."

提交回复
热议问题