Cocoa API解説(macOS/iOS)

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。

目次

アナライズを無視する

Xcodeで静的解析してくれて非常に便利な反面、「それはわかってるからええねん!」と言う事があると思う。
わかっていても非常に気持ち悪い。
そういう時に「ここは解析しなくていいよ」と指示する方法。

#ifndef __clang_analyzer__
...ここが解析されないようになる。
#endif // not __clang_analyzer__     

こういう風に使う

#ifndef __clang_analyzer__
        peakLevels = calloc (2, sizeof (AudioQueueLevelMeterState));
#endif // not __clang_analyzer__     

うん、すっきり!

ありがとうStack Over Flow
http://stackoverflow.com/questions/4587473/xcode-build-and-analyze-is-it-possible-to-purposely-skip-analysis-on-a-particu




追記
他にも警告を出さないようにするコンパイラフラグ。これはGCCからあるのかな。

すべての警告を出さないようにするには"-Wall"

#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wall"
    
    char a = 'bc'; //
    
#pragma clang diagnostic pop   

この変数使われていませんよ!の警告を出さないようにするには"-Wunused"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused"
    
    char a = 'c'; //
    
#pragma clang diagnostic pop

charに複数の文字が入っているよ!の警告をださないのが"-Wmultichar"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmultichar"
    
    char a = 'bc'; // 
    
#pragma clang diagnostic pop

他には...これだけあるらしい。

-Wabi
-Waddress-of-temporary
-Waddress
-Waggregate-return
-Wall
-Wambiguous-member-template
-Warc-abi
-Warc-non-pod-memaccess
-Warc-retain-cycles
-Warc-unsafe-retained-assign
-Warc
-Watomic-properties
-Wattributes
-Wavailability
-Wbad-function-cast
-Wbind-to-temporary-copy
-Wbitwise-op-parentheses
-Wbool-conversions
-Wbuiltin-macro-redefined
-Wc++-compat
-Wc++0x-compat
-Wc++0x-extensions
-Wcast-align
-Wcast-qual
-Wchar-align
-Wchar-subscripts
-Wcomment
-Wcomments
-Wconditional-uninitialized
-Wconversion
-Wctor-dtor-privacy
-Wcustom-atomic-properties
-Wdeclaration-after-statement
-Wdefault-arg-special-member
-Wdelegating-ctor-cycles
-Wdelete-non-virtual-dtor
-Wdeprecated-declarations
-Wdeprecated-implementations
-Wdeprecated-writable-strings
-Wdeprecated
-Wdisabled-optimization
-Wdiscard-qual
-Wdiv-by-zero
-Wduplicate-method-arg
-Weffc++
-Wempty-body
-Wendif-labels
-Wexit-time-destructors
-Wextra-tokens
-Wextra
-Wformat-extra-args
-Wformat-nonliteral
-Wformat-zero-length
-Wformat
-Wformat=2
-Wfour-char-constants
-Wglobal-constructors
-Wgnu-designator
-Wgnu
-Wheader-hygiene
-Widiomatic-parentheses
-Wignored-qualifiers
-Wimplicit-atomic-properties
-Wimplicit-function-declaration
-Wimplicit-int
-Wimplicit
-Wimport
-Wincompatible-pointer-types
-Winit-self
-Winitializer-overrides
-Winline
-Wint-to-pointer-cast
-Winvalid-offsetof
-Winvalid-pch
-Wlarge-by-value-copy
-Wliteral-range
-Wlocal-type-template-args
-Wlogical-op-parentheses
-Wlong-long
-Wmain
-Wmicrosoft
-Wmismatched-tags
-Wmissing-braces
-Wmissing-declarations
-Wmissing-field-initializers
-Wmissing-format-attribute
-Wmissing-include-dirs
-Wmissing-noreturn
-Wmost
-Wmultichar
-Wnested-externs
-Wnewline-eof
-Wnon-gcc
-Wnon-virtual-dtor
-Wnonfragile-abi2
-Wnonnull
-Wnonportable-cfstrings
-Wnull-dereference
-Wobjc-nonunified-exceptions
-Wold-style-cast
-Wold-style-definition
-Wout-of-line-declaration
-Woverflow
-Woverlength-strings
-Woverloaded-virtual
-Wpacked
-Wpadded
-Wparentheses
-Wpointer-arith
-Wpointer-to-int-cast
-Wprotocol
-Wreadonly-setter-attrs
-Wredundant-decls
-Wreorder
-Wreturn-type
-Wself-assign
-Wsemicolon-before-method-body
-Wsequence-point
-Wshadow
-Wshorten-64-to-32
-Wsign-compare
-Wsign-promo
-Wsizeof-array-argument
-Wstack-protector
-Wstrict-aliasing
-Wstrict-overflow
-Wstrict-prototypes
-Wstrict-selector-match
-Wsuper-class-method-mismatch
-Wswitch-default
-Wswitch-enum
-Wswitch
-Wsynth
-Wtautological-compare
-Wtrigraphs
-Wtype-limits
-Wundeclared-selector
-Wuninitialized
-Wunknown-pragmas
-Wunnamed-type-template-args
-Wunneeded-internal-declaration
-Wunneeded-member-function
-Wunused-argument
-Wunused-exception-parameter
-Wunused-function
-Wunused-label
-Wunused-member-function
-Wunused-parameter
-Wunused-value
-Wunused-variable
-Wunused
-Wused-but-marked-unused
-Wvariadic-macros
-Wvector-conversions
-Wvla
-Wvolatile-register-var
-Wwrite-strings