Xcode 3.2.1 and C++ string fails!

前端 未结 2 1699
半阙折子戏
半阙折子戏 2020-12-03 09:04

In Xcode 3.2.1 on Mac OS X Snow Leopard, I open a project under: Command Line Tool of type C++ stdc++. I have the following simple code:

#include 

        
相关标签:
2条回答
  • 2020-12-03 09:53

    As far as I can tell, I'm not experiencing this issue in Release mode for x86_64. But I am seeing the issue in Debug x86_64. If I follow the directions given by Howard in this post, I'm able to get it running in debug mode:

    1. Project -> Edit Active Target ...
    2. Click Build tab
    3. Search for "preprocessor"
    4. Delete _GLIBCXX_DEBUG=1 _GLIBCXX_DEBUG_PEDANTIC=1

    Build and run, you'll notice it works. Another interesting observation is that using __gnu_debug::string (from the <debug/string> header) alone does not trigger the error.

    EDIT: from the horses mouth (known issues in XCode 3.2.1)

    The default gcc 4.2 compiler is not compatible with the Standard C++ Library Debug Mode. C++ programs compiled with Xcode 3.2 may not work in the Debug configuration. To fix this, set the Compiler Version to 4.0, or edit the Debug configuration’s Preprocessor Macros and remove the entries: _GLIBCXX_DEBUG=1 _GLIBCXX_DEBUG_PEDANTIC=1

    You can do this for all projects by navigating to /Developer/Library/Xcode/Project Templates/Application/Command Line Tool/C++ Tool/C++Tool.xcodeproj/ and editing project.pbxproj and deleting the lines around line 138:

    "_GLIBCXX_DEBUG=1",
    "_GLIBCXX_DEBUG_PEDANTIC=1",
    
    0 讨论(0)
  • 2020-12-03 09:57

    An easier way of accomplishing the same thing: paste these lines at the very beginning of your program (before any #include statements):

    #define _GLIBCXX_FULLY_DYNAMIC_STRING 1
    #undef _GLIBCXX_DEBUG
    #undef _GLIBCXX_DEBUG_PEDANTIC
    

    Obviously, this will only affect the current project.

    0 讨论(0)
提交回复
热议问题