PDA

View Full Version : Xcode takes forever to compile!




armyguy26
Jul 6, 2010, 05:21 PM
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.



skunkworker
Jul 6, 2010, 05:29 PM
Well what are you compiling? how much code is there, did you do a clean before building? right now some more information is needed.

armyguy26
Jul 6, 2010, 05:32 PM
Well what are you compiling? how much code is there, did you do a clean before building? right now some more information is needed.

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?

DemonJim
Jul 8, 2010, 12:16 AM
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.

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)