简体   繁体   中英

Gloox XMPP library, EXC_BAD_ACCESS

I'm attempting to code a basic XMPP client with the gloox C++ library. It's my first time using C++ but gloox sounded the most appropriate for my needs and I've got both C and OO experience so I wasn't too worried about trying it.

I have however run into a wall from the start. I can't even get a "hello world" out of my code, instead getting an EXC_BAD_ACCESS error (using Xcode 4).

http://pastebin.com/7vS6ExUV

Here's the code, it crashes on line 35. Gloox mailing list is pretty quite so I thought I'd ask here. Bit worrying there is no gloox tag though!

I'm a little rusty on the old C++ myself, but your main method doesn't look right to me. On line 49 you declare a pointer to an instance of MyClass, but don't allocate it. So you're calling doIt() on at best a null pointer, at worst an garbage object in some random memory space.

Either create a new instance or just drop the pointer. eg:

int main( int argc, char* argv[] ){
   MyClass a; // note, no pointer
   a->doIt();
   return 0;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM