Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

printf

macrumors regular
Original poster
Aug 27, 2008
105
0
msvc++ is a strict compiler that will not let my oversights go unnoticed. xcode, on the other hand seems to be quite forgiving, and i've realized that my lazy programming style is REALLY causing me to spend too much time tracking down bugs that the compiler didn't catch.

i spent almost four hours last night trying to solve a problem and it was all because i had forgotten to declare a function in a header file who's definition with an outdated signature existed in it's respective c file. this function required three arguments, though i only passed in two. everything compiled fine, and the app didn't crash but the results were wrong.

anyway, i looked through the preferences in xcode 2.5 and didn't see anything there that might help me. am i missing something, or is this just something i'm going to have to live with?

thanks!
 

kpua

macrumors 6502
Jul 25, 2006
294
0
All the compiler settings are configured in the project and/or target settings. Double click your project or target to open these settings.

It sounds like you might want to turn all warnings on. There should be a checkbox for it, or you can add -Wall to your Other C Flags. If you're really strict, you can turn all warnings into errors with -Werr. Unfortunately -Wall doesn't really mean all warnings, so read man gcc for more.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Some of the "more" includes -pedantic-errors.

I'm not sure if this will take care of all of it, but as kpua said, the gcc man page will give you plenty of options.

-Lee
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
Select the target, click on "Info", choose the "Build" tab, scroll down to the "gcc 4.0 - Warnings" area and turn warnings on one by one, including "Treat Warnings as Errors". Check their effect. Some are essential (like calling a function without prototype), some improve your code, some or pointless; you decide.

When "fixing" warnings: In many cases there is an underlying problem, fix that, not the warning.
 

EddieDom

macrumors newbie
Jan 9, 2009
5
0
Can't find those options!

Hi.. I'm pretty new to XCode and want to set the compliler options. Everyone keeps pointing at the BUILD tab in the project settings.. but there is no set of fields for setting complier options visible in mine. I'm in ALL SETTINGS and have one line for the compiler... lots of Linker options, but no compiler options. Please help!
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Compiler warnings are at the very end of the list of options:
 

Attachments

  • Picture 9.png
    Picture 9.png
    113 KB · Views: 119
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.