0
Follow
2
View

Clion writing static library encountered a strange problem, I also do not describe clearly, please answer

dexian022 注册会员
2023-02-28 18:18

Although you added macros to your header to prevent double inclusion of hello.h(that is, it doesn't matter if you include both hello.c and main.c), But you can't prevent the variable c you defined from being included twice, so it reports a redefinition error.
When you change it to printf, instead of saying in hello.c, it means that there is no hello.c at this time, and only main.c execution only contains once hello.h, that is, your variable c is only defined once, so there is no redefinition, so there will be no error.