1. Jens Alfke
  2. MYNetwork
  3. Issues
Issue #2 resolved

Compile errors: "‘for’ loop initial declaration used outside C99 mode"

Jens Alfke
repo owner created an issue

(I'm creating this bug on behalf of ssp from [[http://mooseyard.com/Jens/2009/04/myprojects-now-hosted-on-bitbucketorg|an existing comment thread on my blog]]...)

[[http://earthlingsoft.net/ssp/blog/|ssp]] wrote:\ "Unfortunately it fails to compile on my Machine (X.5 / Xcode 3.1.2) with plenty of “‘for’ loop initial declaration used outside C99 mode” errors. I suppose that fiddling with the right compiler option may make that one go away (I think the ‘problem’ are counting variable declarations inside the ‘for’ statement), but I’ll just note that I find open source stuff much more convincing when it compiles right away."

"I didn’t even compile your code inside my project. It looks like the compiler options in your project are set to ‘default’ but really want to be set to ‘C99′. I have no clue about XCode intricacies but perhaps you have an inadvertent ‘C99′ default setting on your system which makes things work out of the box. I assume that making that setting explicit could avoid the problem."

"I re-downloaded the project to make sure I didn’t mess anything up and those compilation errors appeared again. When looking at the Inspector for the project the setting for the C Language Dialect is ‘Compiler Default’. Setting it to xxx99 solved the problem for me."

Comments (11)

  1. Jens Alfke reporter

    It sounds like Xcode isn't finding the .xcconfig files, even though they're added to the project (in the MYUtilities group folder). I looked at that folder and noticed that its location was set to the project-relative path "../MYUtilities", which works for me, or for someone else who's downloaded MYUtilities next to MYNetwork; but if you had put it elsewhere, it wouldn't resolve and none of the files in that group, including the config files, would be found.

    I've changed the folder's "Path type" setting to "Relative to MYUtilities", so assuming you've set up a source path for MYUtilities as per the setup instructions, it should work no matter where it is.

    I've got other changes pending that I'm not ready to check in yet, so I'll need to check out a fresh copy of the repo and apply the change there and check it in... should be ready in a few minutes.

  2. Jens Alfke reporter

    Hm, I cloned a fresh copy of the repo into /tmp and tried building it. As expected the MYUtilities folder and files in it didn't resolve; but the errors I got when building started with

    The file “MYUtilities_Debug.xcconfig” does not exist. (/tmp/MYUtilities/MYUtilities_Debug.xcconfig)

    and continued with lots of errors about headers not being found. I'll check in the fix anyway, but it looks like it may not have been what was causing the bug ssp reported.

  3. Jens Alfke reporter

    Ah, after fixing the path issue, Xcode still can't find the config file:

    The file “MYUtilities_Debug.xcconfig” does not exist. (/tmp/MYUtilities/MYUtilities_Debug.xcconfig)

    and now the following errors are all of the reported "for loop initial declaration..." variety.

  4. Anonymous

    I downloaded this version and it doesn't work for me.

    In fact I'm tempted to say it's worse than it was before (as previously XCode automatically found the files of the MYUtilities download right next to the MYNetwork download which it didn't do now, requiring manual location of the folder.

    I have no clue about that xcconf file business, but it doesn't seem to be working particularly well. Perhaps you should make sure the files are actually used.

  5. Anonymous

    I downloaded this version and it doesn't work for me.

    In fact I'm tempted to say it's worse than it was before (as previously XCode automatically found the files of the MYUtilities download right next to the MYNetwork download which it didn't do now, requiring manual location of the folder.

    I have no clue about that xcconf file business, but it doesn't seem to be working particularly well. Perhaps you should make sure the files are actually used.

  6. Jens Alfke reporter
    • changed status to open

    Are you sure you followed the Setup instructions — steps 1-4 under "How To Build It (Objective-C / Cocoa)"? If you don't have an Xcode "Source Tree" pref configured for MYUtilities, then MYNetwork definitely won't be able to find it now.

  7. Anonymous

    Even though this may not be appreciated I think that projects should build in a single click. When I just want to try stuff out, I rarely want to mess around with technical intricacies to build the damn thing. If you really can't make things work without those extra callisthenics at least make it obvious that they are needed. And by obvious I don't mean a link a few paragraphs into a wiki page the existence of which isn't even apparent on the web page, but a bold warning next to the download link or a README file at the very top of the file list in the XCode project.

    Generally I consider it very unfortunate/bad style to require people to mess up their XCode preferences to use projects. Not only are those preferences a world of mystery, it also means that you may have to undo the changes once you realise that the project doesn't suit your needs. At least I often download stuff just to check it out and see how things are done. Usually I do that directly from my downloads folder and trash the project shortly afterwards. Which in this case means that I'll either have to delete those newly added preferences or, if I want to keep the project around, change them to the permanent location used for storing the folder. Which seems lose-lose to me.

    Of course it's your project, but I find that the frustration associated to open source projects often comes from the fact that they make you perform all sorts of tiny dances to accomodate the quirks of the project. Which in turn makes you wonder whether worth looking at the project to begin with.

    So, yes with your manual setup hints this works, but do you really expect me to find a Wiki page, not be put off by the boring stuff there to find the only relevant (ie related to making stuff work) link there and change up my global XCode settings to do this?

    (But then I'm the guy who also finds it impossible to download the project to begin with as this shitty site prefers to put the link for that outside the browser window…)

  8. Jens Alfke reporter

    Single-click is nice, but MYNetwork has a dependency on a second project. Rather than hardcode a relative path reference between the two source trees, I'm using Xcode's nice "Source Tree" feature that is designed for exactly this.

    I'm not requiring "messing up" Xcode prefs. Adding a source tree doesn't modify any already-existing configuration, can't affect anything else, and won't cause any trouble if you leave it around after deleting MYNetwork/MYUtilities. Since it's a feature that works cross-project, it necessarily has to be configured in a shared location. Maybe the Xcode prefs panel isn't the best place for that, but it's what they decided to do.

    The link to the Setup page wasn't as prominent as it should be; I've improved that. But really, I did point them out to you (with a link) right after you first reported the issue on the 23rd: "Did you read the Setup instructions? They say that pretty clearly, in boldface no less." If you had the link but chose not to follow it, or found the content too "boring", that's your issue (and honestly I can't imagine how you manage to deal with the masses of information that programmers have to deal with.)

  9. Anonymous

    I'm not sure this is the issue other people experienced, but it turned out my problem was I had set the source tree to a location relative to my home directory. Changing this into an absolute path solved it.

  10. Jens Alfke reporter

    Yeah — This happened to someone else too. It turns out that, while Xcode understands '' and will locate the source files in the project (so they don't show up red), GCC does not, so when it looks up #imports it fails. I added a note about this in the Setup instructions.

  11. Log in to comment