Why aren't include guards or pragma once working?

前端 未结 3 710
逝去的感伤
逝去的感伤 2021-02-08 09:47

I\'m compiling some code that relies on include guards to prevent multiple definitions of objects and functions, but Visual Studio 2008 is giving me link errors that there are m

3条回答
  •  走了就别回头了
    2021-02-08 10:02

    If they are linker errors, the most likely cause is probably non-inline functions defined in the header.

    If you have a non-inline function in a header that is included in more than one source file, it will be defined in each of those source files ("translation units"), thus the function will be defined more than once, hence the multiple definitions error.

提交回复
热议问题