Can Klang be used to get started?

I'm just getting started with xcode and learning Objective-C and Cocoa, it would be helpful to swap the compiler in Xcode 3.2 for Clang for advanced error checking and static analyzer. I'm just wondering if the additional services provided would be helpful or would I be better off learning by following the default settings?

many thanks

Gary

+2


source to share


3 answers


There are several uses for CLANG:

  • Run build and analysis to see clang Results.

  • In the project settings for configuration, you can check "run static analyzer" and CLANG will be executed every time you compile.

  • You can also change the compiler from GCC 4.x to CLANG / LLVM. Which displays more errors and CLANG warnings (one example: NSLog(@"A value is %@:%@", value)

    warns you that you are not passing enough parameters).

I would recommend option 2 - if you run a static analyzer with every build it doesn't take long and you find out that you are doing something odd right away instead of fixing a bunch of errors later.Clear messages it gives you , actually provide great educational value, so it makes sense to re-enable it if you're just learning!



3 , - . XCode CLANG/LLVM iPhone, . ( ) "Debug CLANG" CLANG/LLVM . , , ( ), , .

Then, in day-to-day use, you simply use the Debug option to compile with the static analyzer and switch to Debug CLANG, perhaps once a week to see if there are any deeper issues.

+3


source


If you "build and analyze" or enable the "run static analyzer" preference in Xcode, you get Clang static analysis.



Unless you're into C ++ development, it looks like the switch from gcc to Clang hasn't changed significantly. You just don't need to do this to take advantage of Clang's static analysis.

+3


source


You can use a static analyzer without using the actual Clang compiler. Generally, you would not use the parser as the default build option, as it slows down build times by a fair bit.

However, the Clang compiler is a good option even without considering static analysis. As you point out, it has a much better error reporting, but the main advantage is that it is very fast, in fact in my testing it is almost twice as fast as GCC.

+3


source







All Articles