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

armyguy26

macrumors member
Original poster
Apr 8, 2010
43
0
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.
 
Well what are you compiling? how much code is there, did you do a clean before building? right now some more information is needed.
 
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?
 
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:

Code:
#if !defined _HEADERNAME_H
#define _HEADERNAME_H

...

#endif // _HEADERNAME_H

(note <HEADERNAME> must of course be unique for each header)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.