How to set locale (-std) for Clang static analyzer in Qt Creator

I am writing my project in C using QtCreator as IDE and CMake for assembly. QtCreator ver. > = 4.0.0 include the Clang static analyzer, which I am trying to use.

In my set of CMakeLists.txt:

set(CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")

When I run the analysis in the console, get errors:

error: invalid argument '-std=gnu++11' not allowed with 'C/ObjC'

How to pass '-std = gnu99' to the clang analyzer? Maybe it is hardcoded in the sources of the QtCreator plugin?

UDP1 : it looks like this is a QtCreator error: https://bugreports.qt.io/browse/QTCREATORBUG-16290

+4
source share
2 answers

@Petesh.

C, , CMAKE_C_STANDARD CMAKE_C_STANDARD_REQUIRED.

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE)

CMake .

, :

set_target_properties(myTarget
                      PROPERTIES C_STANDARD 11
                                 C_STANDARD_REQUIRED ON)

CMake: . , :

target_compile_features(myTarget
                        PUBLIC c_variadic_macros  # ISO/IEC 9899:1999
                        PRIVATE c_static_assert   # ISO/IEC 9899:2011
)
+3

CMAKE_C_FLAGS C, C++. CMAKE_CXX_FLAGS.

set(CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}")

-std=gnu99 C, :

set(CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}") 
+2

Source: https://habr.com/ru/post/1651569/


All Articles