Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

xcode

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?

like image 371
joshuapoehls Avatar asked Jan 23 '26 10:01

joshuapoehls


1 Answers

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.

like image 57
justin Avatar answered Jan 25 '26 07:01

justin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!