Xcode takes forever to compile!

Discussion in 'iOS Programming' started by armyguy26, Jul 6, 2010.

  1. armyguy26 macrumors member

    Apr 8, 2010
    Hi Everybody,
    When I click build and run on program in Xcode it takes forever to compile. I can't stop it and start over again, I have to force quit Xcode. I have Xcode version 3.2.3. Can anybody help me? Thanks.
  2. skunkworker macrumors regular

    Sep 9, 2007
    Well what are you compiling? how much code is there, did you do a clean before building? right now some more information is needed.
  3. armyguy26 thread starter macrumors member

    Apr 8, 2010
    I am compiling a C code in command line input. There is very little code. (Well on all my codes it takes forever no matter how short or long.) I've tried to reinstall Xcode several times and it doesn't work.

    And, how do you do a clean before building?
  4. DemonJim macrumors newbie


    Jun 19, 2010
    You are probably including a header file which #includes another header file, but this other header file #includes the first one. This is a big no-no!

    So the compiler gets stuck in an infinite loop and its stack grows rapidly and soon eats up all ram and hogs the machine's resources making it harder to kill Xcode the longer you leave it. The best solution is to fix these inter-dependencies.

    There is another way though if you can't find the problem. Objective-C avoids this problem with the #import directive. You can get the same effect in C if you gate all your (#included) headers with something like:

    #if !defined _HEADERNAME_H
    #define _HEADERNAME_H
    #endif // _HEADERNAME_H
    (note <HEADERNAME> must of course be unique for each header)

Share This Page