Xcode 3.2.1 and C++ String Fails!

Xcode 3.2.1 and C++ string fails!

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",

ostringstream problem with int in c++

Changing the Active Configuration in XCode from 'Debug' to 'Release' works as a workaround.

BWToolkit and xcode 3.2.1

Fixed. Problem was in build settings, not sure what exactly as I'v changed many of them

C++: possible Xcode (Mac) problem. Can't read in numbers from external file using getline()

This might work for you. It uses getline as you were trying, but uses the '\'' character to serve as the line delimiter. Ignore everything up to the first '. Assume everything until the next ' is part of a number. Continue until the logic fails (presumably due to end of file).

#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <iterator>

int main()
{
system("pwd");

std::string line;
const std::string fileName = "test.dat";

std::ifstream theStream( fileName.c_str() );

if( ! theStream )
std::cerr << "Error opening file test.dat\n";

std::vector<int> numbers;

while (true)
{
// get first '
std::getline(theStream, line, '\'');
// read until second '
std::getline(theStream, line, '\'');
std::istringstream myStream( line );
int i;
myStream >> i;
if (myStream.fail())
break;
numbers.push_back(i);
}
std::copy(numbers.begin(), numbers.end(),
std::ostream_iterator<int>(std::cout, "\n"));
}

g++ and file read, weird behaviour with Xcode/Snow Leopard

This might be the _GLIBCXX_DEBUG issue - make sure you have the latest Xcode installed, that _GLIBCXX_DEBUG is set the same for all your code and libraries, and you might also want to check the xcode-users mailing list.

Warning: format not a string literal and no format arguments

Are you nesting your brackets correctly? I don't think NSLog() likes taking only one argument, which is what you're passing it. Also, it already does the formatting for you. Why not just do this?

NSLog(@"%@ %@, %@", 
errorMsgFormat,
error,
[error userInfo]);

Or, since you say errorMsgFormat is a format string with a single placeholder, are you trying to do this?

NSLog(@"%@, %@", [NSString stringWithFormat:errorMsgFormat, error], 
[error userInfo]);

bad codegen, pointer diff in boost error in 32-bit build

The problem seems to be fixed in the linker that is installed with XCode 4.2. Upon linking I now get a warning instead of the error message:

ld: warning: direct access in __ZN5boost6detail15sp_counted_baseC2Ev to global weak symbol __ZTVN5boost6detail15sp_counted_baseE means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

Xcode: entering user input when debugging

Are you using the XCode console? You can access it under the "Run" menu, just below the Debugger. The shortcut is command-shift-R. From there you can interact with the application exactly like a terminal, but from inside of XCode itself.



Related Topics



Leave a reply



Submit