![]() |
|
Obj-C++ EXC_BAD_ACCESS errors... - Printable Version +- iDevGames Forums (http://www.idevgames.com/forums) +-- Forum: Development Zone (/forum-3.html) +--- Forum: Game Programming Fundamentals (/forum-7.html) +--- Thread: Obj-C++ EXC_BAD_ACCESS errors... (/thread-5792.html) Pages: 1 2 |
Obj-C++ EXC_BAD_ACCESS errors... - maaaaark - Mar 9, 2005 03:15 PM Could anyone enlighten me as to why I may receive EXC_BAD_ACCESS errors when trying to set member variables of C++ classes? For some reason I cannot access/set any member variables, even if its public/private/protected. For instance, this will crash: (in class.h): public: bool myBool; (in class.cpp): void class::doThis (void) { myBool = false; <-- crashes program } please someone enlightenme. Also maybe this could be why: I'm compiling EVERTYHING as Objective-C++.... (but this shouldn't affect anything, as all .cpp files access some ObjC cocoa stuff in one way or another) Obj-C++ EXC_BAD_ACCESS errors... - Malarkey - Mar 9, 2005 03:27 PM maaaaark Wrote:Could anyone enlighten me as to why I may receive EXC_BAD_ACCESS errors when trying to set member variables of C++ classes? For some reason I cannot access/set any member variables, even if its public/private/protected. Uh, did you instantiate the class somehow using new? I'm assuming you're using pointers here. Obj-C++ EXC_BAD_ACCESS errors... - OneSadCookie - Mar 9, 2005 03:38 PM you're going to need to show us the object's creation. remember, C++ objects that are members of ObjC classes must be initialized using placement new in the ObjC class' initializer. Obj-C++ EXC_BAD_ACCESS errors... - Duane - Mar 9, 2005 03:39 PM Why do you use C++? Obj-C is built for classes, which is the only pro I can see to using C++ over C. Obj-C++ EXC_BAD_ACCESS errors... - maaaaark - Mar 9, 2005 03:49 PM Thank you for bringing that up. I was new-ing child objects, but not the main parent object. I'll blame it on the other developers at work keeping the lights off today... and... the tunnel vision
Obj-C++ EXC_BAD_ACCESS errors... - maaaaark - Mar 9, 2005 03:55 PM Wow that is horrible grammar/spelling. It's been a long day (see above ). Why can't you edit replies... only the thread you start? Or am I missing something.
Obj-C++ EXC_BAD_ACCESS errors... - Steven - Mar 9, 2005 05:42 PM You most certainly can edit replies - look to the bottom right of your post for the 'edit' button. Obj-C++ EXC_BAD_ACCESS errors... - maaaaark - Mar 9, 2005 06:33 PM Maybe it's not in the aqua theme? I'm not seeing it. Obj-C++ EXC_BAD_ACCESS errors... - Steven - Mar 9, 2005 06:36 PM Very strange. It only appears in the very first post. I think I remember this having to do with it only appearing on posts that have titles attached - Carlos? Obj-C++ EXC_BAD_ACCESS errors... - OneSadCookie - Mar 9, 2005 06:52 PM carlos fixed it, but then clearly un-fixed it again :/ Obj-C++ EXC_BAD_ACCESS errors... - iefan - Mar 9, 2005 09:38 PM If your post does not have a title, then you cannot edit it in the aqua theme. So if you use the 'quick reply' box at the bottom you cannot edit without changing themes. I feel that the quick reply should have a default title (whatever the thread is) but that's just me. Obj-C++ EXC_BAD_ACCESS errors... - maaaaark - Mar 10, 2005 07:26 AM I totally agree with that. Otherwise, it leaves users like me feeling like idiots... ...or maybe that has something to do with something entirely different
Obj-C++ EXC_BAD_ACCESS errors... - francosantapy - Jul 30, 2008 08:27 AM I am having the same problem. I found someone saying that was an architecture problem (iPhone is not x86, I think it's ARM) and that you should use a diferent type of alignment, like #pragma options align=something... I tryed putting the members outside and it works (or set the members to static, also works). Some ideas? RE: Obj-C++ EXC_BAD_ACCESS errors... - MuhQ - May 23, 2011 08:11 AM Hi, sorry for digging up this old thread, but I have the exact same problem and maaaaark's solution didn't help (i.e. I didn't understand what to do). In my current project I have two C++ classes, Game (which handles all the game calculations) and GameGraphics (which does all the rendering). I also have an ObjC++ class GameView (for the OpenGL view). GameView has this code: Code: // GameView.h ...I also tried using placement new, although I'm not sure whether I did it right (it didn't help). I've been searching the forum and Google to find a proper way to use C++ classes in ObjC++, but I haven't found anything that solves my problem. (I guess this is in the wrong subforum, but the thread fits my problem.) RE: Obj-C++ EXC_BAD_ACCESS errors... - OneSadCookie - May 23, 2011 08:23 AM NSOpenGLView is not initialized by -init. I don't believe your code will be being called at all. Depending on how you have this set up, you'll either be being initialized by -initWithCoder: or by -initWithFrame:; once you figure out which, you'll know where to initialize graphics. |