Skip navigation
This discussion is archived

10.6 Debug Compiling Problem

9200 Views 6 Replies Latest reply: May 16, 2010 4:17 PM by doofusdan RSS
Paulo Rodriguez Calculating status...
Currently Being Moderated
Sep 18, 2009 1:21 PM
After installing Xcode 3.2, the 10.6 debugger gives some strange results.

I created a new project using: Application->Command Line Tool -> C++ stdc++

Pasted in the code from cplusplus.com for istringstream.

Here is the simple code :

// using istringstream constructors.
#include <iostream>
#include <sstream>
#include <string>
using namespace std;

int main () {

int n,val;
string stringvalues;

stringvalues = "125 320 512 750 333";
istringstream iss (stringvalues,istringstream::in);

for (n=0; n<5; n++)
{
iss >> val;
cout << val*2 << endl;
}

return 0;
}

Console Results for: 10.6|Debug|X86_64 or i386:
0
0
0
0
0


If set to :
10.5|Release or Debug| x86_64 or i386
10.6|Release| x86_64 or i386
Console Results:

250
640
1024
1500
666

Compiling with 10.6 Debug seems to have a problem. I tried doing a clean install of SL 10.6 and clean install of Xcode 3.2, but get same results.

Any suggestions?
17" Macbook pro (late 2007)
  • etresoft Level 7 Level 7 (23,905 points)
    Currently Being Moderated
    Sep 18, 2009 4:21 PM (in response to Paulo Rodriguez)
    Double-click on your Xcode target, select the Build tab, scroll down to "GCC 4.2 - Preprocessing" and delete what is in "Preprocessor Macros". At first, these values just seemed to cause some harmless warning messages, but apparently they also change how software runs (or doesn't).
    MacBook, Mac OS X (10.5.7), 2.0 Ghz/4GB Ram/200 HD
  • etresoft Level 7 Level 7 (23,905 points)
    Currently Being Moderated
    Sep 18, 2009 4:55 PM (in response to Paulo Rodriguez)
    Someone in another thread has already filed a bug about this, but your example was so sweet that I just couldn't resist filing another. I edited your code just a bit to simply and clearly show the bug:

    #include <iostream>
    #include <sstream>
    #include <string>

    #ifdef GLIBCXXDEBUG
    #define GLIBCXX_DEBUGDEFINED "1"
    #else
    #define GLIBCXX_DEBUGDEFINED "<undefined>"
    #endif

    int main()
    {
    std::string svalue("42");
    std::istringstream in(svalue);

    int value;

    in >> value;

    std::cout << "Original value was: " << svalue << std::endl;

    std::cout
    << "With GLIBCXXDEBUG="
    << GLIBCXX_DEBUGDEFINED
    << " value is "
    << value << std::endl;

    return 0;
    }

    Try running with default debug and release settings. Then try debug bug without these macros.

    My bug will certainly be rejected as a duplicate.

    I am beginning to take a perverse pleasure in filing 10.6 bugs.

    But this is a very important plot point - in 10.6 you must remove the macros "GLIBCXXDEBUG=1 GLIBCXX_DEBUGPEDANTIC=1".
    MacBook, Mac OS X (10.5.7), 2.0 Ghz/4GB Ram/200 HD
  • CraigularB Level 1 Level 1 (0 points)
    Currently Being Moderated
    Oct 15, 2009 5:07 PM (in response to etresoft)
    I just wanted to say thanks to this post and this thread in general, I found this when I ran into this exact error while working on a school project. So, thanks for the fix!
    Macbook Pro 4,1, Mac OS X (10.6.1), iPhone 3GS OS 3.0
  • yanhua037 Calculating status...
    Currently Being Moderated
    Jan 2, 2010 3:39 PM (in response to etresoft)
    Thank you so much! I was working on a program which read the file and the same problem occurs. But it's fixed now.
    So do I just remove the code in the Preprocessor Macros? Will it cause any problem in the future? thanks a lot!
    Mac Pro 13', Mac OS X (10.6.2), 2.26 GHZ 2GB RAM
  • doofusdan Level 1 Level 1 (0 points)
    Currently Being Moderated
    May 16, 2010 4:17 PM (in response to CraigularB)
    Ditto - this is my first time using Xcode for C++ (I've used it before for Obj-C/iPhone SDK) and I was just about to switch back to Visual Studio!
    Mac OS X (10.6.3)

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.