Xcode reports triple errors

Discussion in 'Mac Programming' started by Stratoukos, Dec 10, 2009.

  1. Stratoukos macrumors member

    Joined:
    Jul 15, 2008
    #1
    Lately, Xcode started displaying, in one of my projects, every error I make three times. The project is a C++ command line tool. For example if I write:
    Code:
    int i = "asd";
    it should display 1 error for assigning a const char* to an int and 1 warning for the unused variable. Instead I get 3 errors for the assignment and 3 warnings for the unused variable(screenshot). It's not a big deal, since when I fix any errors it builds normally and it only affects this project, but if it's something easy I would like to fix it.

    Thanks!
     

    Attached Files:

  2. kpua macrumors 6502

    Joined:
    Jul 25, 2006
    #2
    Are you building 3-way FAT? If so, then each file is compiled 3 times, resulting in 3 times the errors.
     
  3. Stratoukos thread starter macrumors member

    Joined:
    Jul 15, 2008
    #3
    Yes, that's it. I didn't think of fat binaries, because building 3-way fat binaries is the default and every other project reports each error once. The reason that I get triple errors in this one is that I'm not making debug builds but release. I usually build in debug configuration while developing and make a release build when I'm done, and since there are no errors when I'm done I never noticed before. Because of a bug in Xcode (something with fstream), I can't make debug builds and i noticed the triple errors.

    Thanks.
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    What kind of bug is preventing you from making a debug build?
     
  5. Stratoukos thread starter macrumors member

    Joined:
    Jul 15, 2008
    #5
    I have a file that has a series of doubles separated by spaces/newlines that I want to read from. This code:

    Code:
    #include <iostream>
    #include <fstream>
    #define SIZE 2000
    
    int main(argc, *argv[]) {
        ifstream file("filename", ios::in);
        double d[SIZE];
        for (int i=0; i<SIZE; i++) {
            file>>d[i];
            std::cout<<d[i];
        }
    }
    would print the correct values when compiled in release or from g++ in terminal, but it would only print zeros when compiled in debug.

    Here is where I read that it's a bug. There is also a fix, but since it's only an assignment for my university I just flipped the switch to release and kept working.
     

Share This Page