• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
XCode, cin and string (C++) => troubles :s
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

XCode, cin and string (C++) => troubles :s


  • Subject: XCode, cin and string (C++) => troubles :s
  • From: Arnaud Schoofs <email@hidden>
  • Date: Sun, 14 Feb 2010 12:38:51 +0100

Hi everyone,

I'm trying to use XCode (in place of Eclipse) for developping a basic
C++ app but i've got some troubles :/

- Under Eclipse (on linux) : no problem : compilation OK, execution OK
- Under OS X with a makefile : no problem : compilation OK, execution OK
- Under OS X withe XCode : compilation OK, execution : KO !!
There is an error when executing the part of the code using string. En
error like this one :
helloworld(2945) malloc: *** error for object 0x40e4: pointer being
freed was not allocated
*** set a breakpoint in malloc_error_break to debug
(but the program continue to run)
(NB : the part of the app using char* works well)

So I guess i've got a problem of configuration/tuning in XCode but i don't know what :s

To help me answer this question i've prepared a .zip containing :
- the makefile i'm using (the app produced with it is fully working on os x)
- source code (main.cpp)
- the app compiled with the makefile (main.o and helloworld_makefile)
- the XCode project (helloworld.xcodeproj)
- the app compiled with XCode (buil/Debug/helloworld)
Here is the .zip : http://lepommier.boinc-af.org/public/helloworld.zip

I'm using Mac OS X Snow Leopard on a Macbook Core Duo (i.e. 32bits) and XCode 3.2.1

Thanks for your help.

(Sorry for the gram/orth mistakes, i'm not a native speaker)

------------------------------------------------
For those of you who don't trust the zip :
soure code :
#include <iostream>
using namespace std;
int main (int argc, char * const argv[]) {
	string s;
	cout << "Type something (using string) : ";
	cin >> s;
	cout << s << "\n\n";
	char* c;
	cout << "Type something (using char*) : ";
	cin >> c;
	cout << c << "\n\n";
    return 0;
}

makefile:
CPP=g++
CXXFLAGS=-Wall -ansi -pedantic
LDFLAGS=
EXEC=helloworld_makefile
SRC= $(wildcard *.cpp)
OBJ= $(SRC:.cpp=.o)
all: $(EXEC)
helloworld_makefile: $(OBJ)
	$(CPP) -o $@ $^ $(LDFLAGS)
%.o: %.cpp
	$(CPP) -o $@ -c $< $(CFLAGS)
.PHONY: clean mrproper
clean:
	rm -rf $(DIRSRC)*.o
mrproper: clean
	rm -rf $(EXEC)

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: XCode, cin and string (C++) => troubles :s
      • From: Andreas Grosam <email@hidden>
  • Prev by Date: Re: Xcode performance issues over time
  • Next by Date: coredata in instruments (iPhone)
  • Previous by thread: Re: Upon break, debugger not showing correct line in source
  • Next by thread: Re: XCode, cin and string (C++) => troubles :s
  • Index(es):
    • Date
    • Thread