C++ #include guards

后端 未结 8 839
鱼传尺愫
鱼传尺愫 2020-11-22 13:24

SOLVED

What really helped me was that I could #include headers in the .cpp file with out causing the redefined error.


I\'m new to C++ but I have some p

8条回答
  •  温柔的废话
    2020-11-22 13:32

    Add include guards in all your *.h or *.hh header files (unless you have specific reasons to not do that).

    To understand what is happening, try to get the preprocessed form of your source code. With GCC, it is something like g++ -Wall -C -E yourcode.cc > yourcode.i (I have no idea on how Microsoft compilers do that). You can also ask which files are included, with GCC as g++ -Wall -H -c yourcode.cc

提交回复
热议问题