-Wunused is not active for Clang

17 views
Skip to first unread message

Lei Qiao

unread,
Aug 9, 2015, 5:58:40 PM8/9/15
to deal.II User Group

Dear all,

 A piece of my own code got two -Wunused warnings when compiled with gcc on linux system.
 But every thing finished silently with Clang on my Mac.

Is this a designed feature of the deal.II CMake system?

Best,
Lei

Matthias Maier

unread,
Aug 9, 2015, 6:02:45 PM8/9/15
to dea...@googlegroups.com
> Is this a designed feature of the deal.II CMake system?

To some extend, yes. Have a look at the output of detailed.log

Details can be found in cmake/setup_compiler_flags_gnu.cmake:

79 IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# [...]
92 ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-unused-parameter")
93 ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-unused-variable")
# [...]
100 IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.6")
101 #
102 # Clang versions prior to 3.6 emit a lot of false positives wrt
103 # "-Wunused-function".
104 #
105 ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-unused-function")
106 ENDIF()
107 ENDIF()

Lei Qiao

unread,
Aug 9, 2015, 6:16:16 PM8/9/15
to deal.II User Group
Thank you for your instantaneous response.

So, is there any way to enable these warning's for user code?

Matthias Maier

unread,
Aug 9, 2015, 8:47:19 PM8/9/15
to dea...@googlegroups.com
> So, is there any way to enable these warning's for user code?

You have two options:

(a) Quick'n'dirty: Look for lib{...}/cmake/deal.IIConfig.cmake
in your installation and remove the flags you don't want to have.

(b) Directly after the inclusion of the project configuration with
FIND_PACKAGE(deal.II ...)
in your CMakeLists.txt file, you can filter out all unwanted strings
in the variables DEAL_II_CXX_FLAGS, DEAL_II_CXX_FLAGS_RELEASE and
DEAL_II_CXX_FLAGS_DEBUG.

Best,
Matthias

Lei Qiao

unread,
Aug 9, 2015, 8:51:43 PM8/9/15
to deal.II User Group
Great. I choose (b), once for all.

Thank you.
Reply all
Reply to author
Forward
0 new messages