How does the linker know where is the definition of an extern function?

后端 未结 4 1130
日久生厌
日久生厌 2021-01-12 07:29

I read a few posts and concluded that extern tells compiler that \"This function exists, but the code for it is somewhere else. Don\'t panic.\" But how does the linker know

4条回答
  •  半阙折子戏
    2021-01-12 08:07

    The simple answer is that "the compiler doesn't need to know, but the linker has to be able to find it". Through multiple .o files, or through libraries, the linker has to be able to find a single definition of the GrCircleDraw function.

提交回复
热议问题