CMake and compiler warnings

后端 未结 2 1645
轮回少年
轮回少年 2021-01-01 11:39

I use CMake to generate unix makefiles. After that I compile project using make utility. Problem is that I can\'t see any warnings! For example, th

2条回答
  •  青春惊慌失措
    2021-01-01 12:32

    Solve problem with this line of code:

    add_definitions ("-Wall")
    

    Result now looks like this:

    [100%] Building CXX object CMakeFiles/main.dir/main.cpp.o
    ../src/main.cpp:15:2: warning: #warning ("Custom warning") [-Wcpp]
    ../src/main.cpp: In constructor ‘WarnSrc::WarnSrc(int, int)’:
    ../src/main.cpp:6:9: warning: ‘WarnSrc::second’ will be initialized after [-Wreorder]
    ../src/main.cpp:5:9: warning:   ‘int WarnSrc::first’ [-Wreorder]
    ../src/main.cpp:8:5: warning:   when initialized here [-Wreorder]
    ../src/main.cpp: In function ‘int main(int, char**)’:
    ../src/main.cpp:19:9: warning: unused variable ‘unused’ [-Wunused-variable]
    ../src/main.cpp:20:9: warning: variable ‘x’ set but not used [-Wunused-but-set-variable]
    Linking CXX executable main
    [100%] Built target main
    

提交回复
热议问题