|
I've been driving myself nuts for a few days just trying to set up a simple callback. I think I need some Barney-level help. I have two questions: Firstly, this is the simplest kind of callback class that I have found: code:
Second question: code:
|
# ¿ Mar 2, 2008 01:24 |
|
|
# ¿ May 3, 2024 20:18 |
|
Avenging Dentist posted:You can't specialize 0 of the template parameters, so it's not a specialization at all. (i.e. remove <Class, ReturnType>) Avenging Dentist posted:Make a base class for GUIButtonCallback to inherit from and use virtual functions. That is,
|
# ¿ Mar 2, 2008 03:12 |
|
Why is my "this" pointer changing on every line of execution? My program is crashing because this is changing to something weird like 0x00000001 or 0xffffffff or random junk as I step through the program. The functions worked fine with an earlier build but now I am converting everything over to use wxWidgets and now this is happening all over the place. I am having a lot of trouble searching as "this" isn't exactly a unique word. Edit: Actually maybe I have no idea what is going on. Is "this" as it shows up in the debugger supposed to change? Is it showing me the address of this, or something else? I went back to my old implementation and this never changes in any function. Edit 2: Why are these pointers "expression cannot be evaluated"? They were just newed. very fucked around with this message at 03:55 on Mar 13, 2008 |
# ¿ Mar 13, 2008 02:27 |
|
Thanks both of you. The thing that confuses me is that the entire program runs just fine even though this is pointing all over the place. I just tried adding one feature and one of the libraries I am using was sensible enough to crash when I passed it a this pointer value 0x00000001 and that is why I noticed the problem in the first place. wxWidgets says to turn off optimization for "bizarre problems" and I guess this is a bizarre problem, so I did that and it works now. Maybe I need up upgrade to VC++ 2008, but I'm afraid I will have to recompile every library I am using and I'll never get up and running again. vvv I didn't realize they were on. I don't know why VC++ sets up the Debug configuration just like a release configuration by default when you do an empty project. very fucked around with this message at 05:07 on Mar 13, 2008 |
# ¿ Mar 13, 2008 04:50 |
|
I traced the actual problem I am having down to a function in a library that I am using (bullet) where the wrong function is being called. They aren't even the same prototype, or even in the same class hierarchy. The function that is supposed to be called is a simple getCount() type thing that returns an int, but the program actually goes to a different function entirely that returns a void, thus passing on garbage to the caller. The function that gets called takes some arguments by reference, so it is probably doing even more damage by clobbering whatever happens to be in those spots. Does anybody know what would generally cause the wrong function to be called? I'm using VC++ express 2005. A friend of mine thinks that the memory where function addresses are stored is getting clobbered somehow. Is that even possible? Would VC++ just let me do that? I put the code that breaks at the very beginning of my program and stepped through it with no other threads running, but it still goes to the wrong function. I've also since rebuilt the library, but that didn't fix it either.
|
# ¿ Mar 18, 2008 17:19 |
|
HB posted:It wouldn't *knowingly* let you do that (not in C++, at least), but it can certainly get corrupted. Ok. I see something new here: The caller's type is btPrimitiveManagerBase *, and the function being called is defined in there as virtual int get_primitive_count() const = 0; This obviously shouldn't work, right? The thing that bothers me is that it does work just fine in an earlier version of my program. The difference being that I switched to using wxWidgets for my interface. I don't know how this is related, but it was such a major overhaul that I can't really pinpoint one thing that made it break. In the version that works, the caller is still a btPrimitiveManagerBase *, but the function that gets called is in this class: code:
|
# ¿ Mar 18, 2008 17:58 |
|
Thanks for your help. Apparently it was VC++'s retarded defaults for empty projects that got me again. I went through and made sure everything was the same as another project (it wasn't). It works now but I'm not even sure which option was the culprit. I guess I could pull the old one out of SVN if I really want to find out, but I'd rather forget about it.
|
# ¿ Mar 19, 2008 01:23 |
|
I've tried many C++ IDEs on Linux and I've found eclipse to be the least bad, but I'm not sure if it is better than a basic text editor. Visual Studio is still so much better.
|
# ¿ Oct 20, 2009 01:39 |
|
Avenging Dentist posted:emacs is anything but "basic". I don't think it fits into the category of "basic text editor," no. Using gdb in emacs can be quite nice... but I don't enjoy editing text in emacs.
|
# ¿ Oct 20, 2009 01:47 |
|
Your destructors should be called as many times as your constructors.
|
# ¿ Nov 6, 2009 07:09 |
|
A warning was brought to my attention.
|
# ¿ Nov 21, 2009 23:50 |
|
|
# ¿ May 3, 2024 20:18 |
|
Screeb posted:I thought about a custom allocator, but I know poo poo all about them. I had a read earlier and they're kind of confusing I only have a bit of experience with this type of thing but I'm pretty sure it will solve your problems as far as speed and fragmentation.
|
# ¿ Dec 10, 2009 16:31 |