make my program work when one project has two c program files

Discussion in 'iOS Programming' started by ssaeed, Jan 13, 2012.

  1. ssaeed macrumors newbie

    Joined:
    Jan 13, 2012
    #1
    I cant seem to make my program work when one project has two c program files! it says build failed without exit code 1. can anyone please help?
     
  2. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #2
    Without exit code 1? ;)

    Are you using Xcode? Can you paste a screenshot? You have not given us very much information to help you...
     
  3. ssaeed thread starter macrumors newbie

    Joined:
    Jan 13, 2012
    #3
    sure! and sorry but it says failed with exit code 1 if i try to program more than 1 file in one destination.
     

    Attached Files:

  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    You can't have the same C function name twice in a single executable. So you can only have main once. Which is exactly what the error tells you.
     
  5. ssaeed thread starter macrumors newbie

    Joined:
    Jan 13, 2012
    #5
    im sorry i dont understand! one file has name "main" and the other has "blah". Why is it not possible to program more than one file in one project? thanks
     

    Attached Files:

  6. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #6
    He's not talking about the file name but the function name. blah has a main() function.
     
  7. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #7
    Exactly. This has absolutely nothing to do with the number of files or the file names. If you copy and pasted the content from blah to the other file and only had one file you'd get the same problem as there would be two main functions. Functions are globally scoped so you cannot have the same function name twice regardless of which file it is in.
     
  8. ssaeed thread starter macrumors newbie

    Joined:
    Jan 13, 2012

Share This Page