PointCloudLibrary/pcl

Reduce warnings during compilation with all (usual) warnings switched on

Open

#2,746 建立於 2018年12月27日

在 GitHub 查看
 (9 留言) (1 反應) (0 負責人)C++ (4,506 fork)batch import
effort: mediumgood first issuekind: todomodule: cmakeplatform: linuxplatform: windows

倉庫指標

Star
 (9,023 star)
PR 合併指標
 (平均合併 8天 7小時) (30 天內合併 3 個 PR)

描述

To increase code quality of new PR, we should treat warnings as errors (as already mentioned here #2733).

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")

In case we have not solved all compiler warnings, before introducing this change, we have to whitelist this warning types (global or per target).

Because with new compilers sometimes new compiler warnings will be introduced, we should care about this:

  • Option 1: Instead of -Werror explicitly list all warning types which should treat as error (this list could be really long), so new warnings will be not treated as error
  • Option 2: Add an option to enable/disable this change.
if(CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GCC)
  option(PCL_Treat_warnings_as_errors TRUE) # TRUE or FALSE as default?
  if(PCL_Treat_warnings_as_errors )
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
  endif()
endif()

Before we can introduce this, we need to resolve #2732 & #2745, so 3rd-party code cannot raise warnings.

貢獻者指南