Multiple definition error on variable that is declared and defined in header file and used only in its cpp file

后端 未结 3 1531
盖世英雄少女心
盖世英雄少女心 2021-01-23 05:17

I\'m in the process of moving code written to be compiled for one chip onto another chip.

One issue that\'s come up is a multitude of multiple definition errors. Some of

3条回答
  •  -上瘾入骨i
    2021-01-23 06:13

    in C++ 17 you can resolve this issue by inline variables. Inline variables avoid the duplication of variables defined in header files. The variables defined in the header file will be treated as initialized in a cpp file. They won't be duplicated. So can be directly included the code.

提交回复
热议问题