stricter carbon compiler options in xcode?

Discussion in 'Mac Programming' started by printf, Oct 9, 2008.

  1. printf macrumors regular

    Aug 27, 2008
    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?

  2. kpua macrumors 6502

    Jul 25, 2006
    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.
  3. lee1210 macrumors 68040


    Jan 10, 2005
    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.

  4. gnasher729 macrumors P6


    Nov 25, 2005
    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.
  5. EddieDom macrumors newbie

    Jan 9, 2009
    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!
  6. Sayer macrumors 6502a


    Jan 4, 2002
    Austin, TX
    Compiler warnings are at the very end of the list of options:

    Attached Files:

Share This Page