Source files saved on non mac-os machines.

Discussion in 'Mac Programming' started by arvz, Aug 12, 2008.

  1. arvz macrumors newbie

    Joined:
    Aug 10, 2008
    #1
    Hey guys,

    I have this really annoying problem with Xcode.

    Heres a bit of a background first:

    I am a uni student and my uni's computing department runs Linux on the computer labs. All of my work are saved in the uni's network which I can access from anywhere using sftp.

    The Problem:

    When I open some of my .c files that I had been working on at uni, it would crash Xcode. I am running Mac OSX Leopard 10.5.4 and using Xcode 3.1

    What I've tried (Which didn't help):

    1) Restart
    2) Reinstall
    3) Pulled my hair out :mad:
    4) Played around with some other .c files at the uni server which didnt crash
    5) Copied the file to my HD instead of opening it remotely
    6) Disabling auto-indentation
    7) Created a new file and copy-pasted my code into it

    The Analysis so far:

    - It seems that the crash is caused by indentation errors.
    - Not every file causes the crash, some of my shorter programs opened just fine.
    - If I convert the .c file that crashes into an .odt file, Xcode does not crash opening it.
    - Xcode has no problems opening files that it itself created/saved

    How did I conclude that it has something to do with indents?

    I went and removed ALL indentation on my crashing program. Doing this enables Xcode to open the program without crashing. Another thing to note also is my program's indentation was normal when I open it at uni, or even on my PC. When I open it on my mac some parts were a little over-indented or under-indented, lines would just start on the same point instead of different indent points, etc..

    Concluding comments

    If everytime I wanna use Xcode I have to remove all indentation and re-indent inside Xcode I may as well pull my fingers off. Does anyone know how to deal with this?
     
  2. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #2
    What version of Xcode are you using? Before doing anything else, I'd check to see if you have the latest. 2.5 for Tiger and 3.1 for Leopard.

    That said, indentation shouldn't cause Xcode to crash - unless you've got an encoding conflict (i.e. the encoding the .c files are saved in at Uni is confusing Xcode when it tries to interpret it). If that's the case make sure the files are the same encoding on both (UTF-8 is a safe choice).
     
  3. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #3
    Sounds like a line ending problem.

    Go to the Preferences menu item in Xcode and click the Text Editor tab. Make sure it is setup like in the picture below.

    If that doesn't fix it, can you tell us what other editors you have used to work on the files before? Maybe they are saving the files in a dodgy way.
     

    Attached Files:

  4. arvz thread starter macrumors newbie

    Joined:
    Aug 10, 2008
    #4
    For version of Xcode:

    As for line ending, that is exactly the way my Xcode is set up as your screenshot shows.

    At uni I use Linux's Text Editor G-edit, on Gnome
     
  5. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #5
    My next suggestion - when you get a chance, check your G-edit settings. Is it also set to save files as UTF-8 with Unix (LF) line endings? Those are the two important settings.
     
  6. zmttoxics macrumors 65816

    zmttoxics

    Joined:
    May 20, 2008
    #6
    I would recommend to stop using gedit (the real way its spelt). gedit is NOT an IDE but rather a document editor, and as such tampers with files by putting in control characters that you can't see. If your lucky enough you can open the file in vi through a terminal and you might see the control characters and be able to remove them. These things are bad enough that they can screw up your syntax when compiling and you will never see the error.

    I recommend using either a command line text editor (vi, nano, pico, mcedit, emacs, what have you) or an IDE such as NetBeans, Eclipse, KDevelop, etc.
     
  7. arvz thread starter macrumors newbie

    Joined:
    Aug 10, 2008
    #7
    well I don't have a problem with IDEs, Xcode is pretty good, and Eclipse does a great job as well, but I do most of my coding using a windows software development text editor called ConTEXT. I think that most text editors built for programming do a great job, it is probably just G-Edit that screws up, since it is essentially just a normal text editor souped up with syntax highlighting.

    I opened up my program with vi but I don't see the control characters

    what command do I use? i tried:

    vi eval.c

    and vim eval.c (which did the same thing) but i dont see any control characters.
     
  8. zmttoxics macrumors 65816

    zmttoxics

    Joined:
    May 20, 2008
    #8
    Ya, as I said - only if your lucky. Its best to just type the whole thing out again in a different editor.
     

Share This Page