View Full Version : Carbon Help Needed (Mac OS X [jaguar])
tricolaire
07-01-2005, 05:06 AM
I'm trying to write some basic carbon code, and condense it into a header file.
Attached is the source code
I'm compiling and running the application through the XCode IDE
Every time the "run test" button is pressed, the program "exits with signal 10 (sigbus)"
please help!
Hey I don't code much at all for carbon so I can't be of much help, but I did notice that it looks like you are trying to copy 4 bytes of data into an unitialized pointer, which could be a big problem.
char *textBuffer;
CFStringGetCString(text,textBuffer,sizeof(char*),0); // <-- bad thing!
The docs for CFStringGetCString() don't say anything about allocating memory for you.
sizeof(char*) is acutally 4 bytes on most intel machines, not sure about macs, but either way it's most likely wrong because textBuffer is unitialized.
Try it like this:
char textBuffer[256] = {0};
CFStringGetCString(text,textBuffer,sizeof(textBuffer),0);
That may or may not be your problem, and beyond that you should also learn how to use a debugger to find problems.
tricolaire
07-01-2005, 01:26 PM
I would pay large amounts of cash to anyone who can teach me how to use the XCode debugger ;) , it should be easy if it's at all similar to vc++, but I can't figure it out :(
tricolaire
07-01-2005, 01:32 PM
I ran the code with the suggested corrections, and everything works, until I get to the printf function call. I tried putting the variable (textBuffer) into a puts statement and the "\n" into a printf, but textBuffer is printed as empty, so all that happens is a "\n" being printed whenever the button is pressed. any ideas?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.