c++ - gcc (mac/linux) error no matching function for call while VisualStudio compiles ok -
i've got problem cross-platform compile. code below compiles on win, mac , linux (program qt based) in order make compile on mac , linux have defined if/else.
windows compiler (vs2010) finds definition mac (gcc4.2) , linux (ubuntu12lts) cant find it...
any ideas? maybe im missing technical terminology in order search this? want able use "table->setmark(i,myobj());" systems doesnt seem have platform specific code.
///// .h void setmark(int row, myobj& mark) { value(row).setmark(mark); } const myobj& getmark(int row) const { return value(row).getmark(); } ///// ///// .cpp myobj obj; bool ret = false, ifhandled = false; m_root_command.evaluate(obj,ret,ifhandled); if (m_marked) { table *table = m_thisobj.gettable(); (int = 0; < table->getrowcount(); i++) { #if defined(_win32) // works in windows, fails compile // on other platforms error below table->setmark(i,myobj()); #else // want rid of workaround // , use above code platforms myobj objtmp = myobj(); table->setmark(i,objtmp); #endif } m_marked = false; } ///// ///// error program.cpp: in member function 'myobj program::evaluate()': program.cpp:264:36: error: no matching function call 'table::setmark(int&, myobj)' program.cpp:264:36: note: candidate is: table.h:326:9: note: void table::setmark(int, myobj&) table.h:326:9: note: no known conversion argument 2 'myobj' 'myobj&' make: *** [program.o] error 1 /////
you cannot bind temporary non-const reference. use table->setmark(i,myobj());
need change declaration
void setmark(int row, myobj& mark)
into
void setmark(int row, const myobj& mark)
likewise setmark
function delegates to.
edit: fact works in vs apparently known bug/feature
Comments
Post a Comment