Dragonfly Q&A

OListIterator Error, cannot convert arguement from OList* to const OList*.

0 like 0 dislike

I am having a problem compiling WorldManager as the compileris giving me the error message C2664: cannot convert arguement 1 from "df::ObjectList *" to "const Dragonfly ObjectList *".  This occurs at the code:

ObjectList list; // create new list to hold return value
ObjectListIterator li(&updates); // create iterator to go over list
 
ObjectListIterator li(&deletions); // iterate over deltions list
 
ObjectList ol = updates; // copy list so can delete during iteration
ObjectListIterator li(&ol);
 
I am unsure of what is wrong here and any help would be appreciated.

 

Dragonfly version 4.2
asked Sep 11, 2016 in Engine Development by wakelley

1 Answer

0 like 0 dislike
Do you have a "DragonflyObjectList" class?  it sounds like you do.  My guess is that your "updates" and "deletions" attributes are of type DragonflyObjectList and the type needed in your ObjectListIterator constructor is "ObjectList *", hence the error.  You don't want these classnames/types to be different.
answered Sep 11, 2016 by claypool
I do not have a second ObjectList class, in WorldManager.h both updates and deletions are made as type df::ObjectList, and iterator operates on (const ObjectList *p_l) with ObjectList being a df::ObjectList as you provided in objectlistiterator.h, nowhere in my code does a DragonflyObjectList exist outside of the error message and that is what has me confused. It is trying to convert something from the proper type into something else and making up a nw type to accept as the output. Is it possible the error is due to const?
Converting a non-const * to a const * is fine (of course, the reverse is not fine).  But the error says it can't convert ao "DragonflyObjectList *" to an "ObjectList *".  So ... my guess is either the error message is not exactly what you are indicating or you have a spurious declaration syntax issues that is causing the mis-matched types.

If you can't find it yourself, you can zip of your project and put it someplace where we can download it and I can take a look (you can't email it - WPI email strips off zip files).

------------------------------

Ok, after looking at your code.  The error message is not "Dragonfly ObjectList" but rather "df" - this suggests the namespace.  Make sure to check/paste the error message carefully, as it will help find the mistake if you ask for help.

You have your forward declarations - "class ObjectList;" in "ObjectListIterator.h" and "class ObjectListIterator;" in "ObjectList.h" - outside of the namespace df.  You need to move those inside the namespace.

Ok now that is fixed a different error popped up, copy pasted from error bar:

Severity Code Description Project File Line Suppression State
Error
 
LNK2019
 
unresolved external symbol _WinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
 
Dragonfly C:\Users\william\Documents\Visual Studio 2015\Projects\dragonfly\MSVCRTD.lib(exe_winmain.obj)
 
1
 
Again any help would be greatly appreciated.
Not sure - a google search gives some suggestions:

http://stackoverflow.com/questions/35067514/linker-error-unresolved-external-symbol-winmain16-when-building-console-appli

Also, make sure to link in sfml-main-d, too.
Thanks I figured it out and it works now.
More information about Dragonfly can be found on the Dragonfly Home Page.
...