joshuapoehls
joshuapoehls

Reputation: 35207

How do I make XCode show me warnings in my C code?

When I build using a Makefile I add -Wall -g to my gcc args to get warnings.

So when I build this code:

#include <stdio.h>

int main()
{
}

I get this warning:

main.c: In function ‘main’:
main.c:10: warning: control reaches end of non-void function

However when I build the same code in XCode I don't see any warnings.

I think XCode is using LLVM instead of GCC but there must be an equivelant. How can I turn this on in XCode?

Upvotes: 3

Views: 418

Answers (1)

justin
justin

Reputation: 104698

I think XCode is using LLVM instead of GCC but there must be an equivelant. How can I turn this on in XCode?

You can choose the compiler from the build options area.

  1. Click the project in the navigator
  2. Click the desired target
  3. Click Build Settings
  4. set GCC_VERSION in the search field below.
  5. Choose the compiler to use.

If you clear the search field now, you can scroll down to enable specific warnings.

Note that LLVM + GCC is the GCC front end with a LLVM optimizer.

Clang doesn't support all the options GCC does. It also supports a few new ones, or differences. So it's a good idea to build against both.

Upvotes: 1

Related Questions