How can I avoid the LNK2005 linker error for variables defined in a header file?

后端 未结 7 1395
情话喂你
情话喂你 2020-12-19 09:28

I have 3 cpp files that look like this

#include \"Variables.h\"
void AppMain() {
    //Stuff...
}

They all use the same variables inside th

7条回答
  •  囚心锁ツ
    2020-12-19 09:58

    I know that this is an old thread, but I came across this as one of the first search results from Google. I solved the problem by placing the variable static.

    namespace Vert
    {
       static int i;
    }
    

    I tried extern and in my situation that didn't seem to solve the problem.

提交回复
热议问题