-
stl::list error
I am using the standard template library function list. I have made a list and a iterator but the problem is mainly with the iterator.
This is the code that is giving the error:
I also get a warning:
Code:
warning C4251: 'D3dEngine::Engine::textlist' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'D3dEngine::Engine'
The error that happens is a standard windows error saying the program had to close.
-
That warning is telling you that unless you add Code:
__declspec(dllexport)
(I think that's the bit you need) to your declaration, your iterator won't be available for use outside of the library you're building. As for the problem, I'd need to see some code before and after that line to have any chance of knowing why incrementing the iterator is failing (though a quick check of initialization and past-end-of-list conditions would be MY starting point, hint hint).
-
Ok were here is were I declared the list and iterator:
Code:
std::list<FONT> textlist;
std::list<FONT>::iterator textiter;
That is declared in my private part of the class, but that shouldn't matter sence only the class uses it.
Than here is were I use it inside the class:
Code:
for (textiter = textlist.begin(); textiter != textlist.end(); ++textiter)
{
//Code here, non yet
}
I even tried adding a if statement to see if it was empty, and if it wasn't do that. But I still got the same error.
-
Make it public and see what happens.
-
If you don't have any code in your for loop, how do you know the ++textiter is what's causing the problem? That loop should do nothing (and might even be compiled away, depending on compiler options!), so I'd guess that the error is most likely caused by the first instruction AFTER the loop. Can you supply a little more context? Or are you stepping through with the debugger to see this happen?
-
oh sorry yes I used the visual c++ 2005 express debugger and my own ways. I am 99% sure that the ++iter is causing it, and that is why I am stumped. I even tried the while loop with the iter.
-
Is there any way you can post/paste somewhere the full class and/or driver program? I'd still bet against it being in the ++iter (unless VC++2k5 Express has a bug...), but with this level of information, it's almost impossible to help (at least for me - someone smarter than me might be able to).
-
Well 5 posts up is all the information you should need, the rest of the class is direct x stuff wich works fine. My guess is it has to do with the dll and using the dll.
I'm really not sure what to do now, I guess I can make do without or make my own semi list type thing.
-
I still think the issue is NOT in the std::list code, but I could be wrong - does it run w/o error if you comment out the loop?
-
yup.
if I use a while look and the ++itter is inside the while loop but I comment out the ++iter it works. But if I put it back in it gives the error.
-
so the line works inside the body of the while loop, but not in the for() construct? That's just weird.
-
lol sorry let me make my self more clear.
++textiter does not work in either place. The purpose of the while loop was to prove ++textiter was causing the problem.