Error: no operator "==" matches these operands - c++

This isn't actually my code, but I need help right here. Since I'm new to coding, I don't know how to fix this problem.
bool GetProcessEntryByName(string name, PROCESSENTRY32* pe) {
auto snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (snapshot == INVALID_HANDLE_VALUE) {
cerr << "Tool helper cannot be created" << endl;
return false;
}
if (!Process32First(snapshot, pe)) {
cerr << "Tool helper cannot retrieve the first entry of process list" << endl;
return false;
}
do {
if (pe->szExeFile == name) {
snapshot ? CloseHandle(snapshot) : 0;
return true;
}
} while (Process32Next(snapshot, pe));
snapshot ? CloseHandle(snapshot) : 0;
return false;
}
And the error occurs at: if (pe->szExeFile == name)....
Output:
1>------ Rebuild All started: Project: EzExecV2, Configuration: Debug x64 ------
1>main.cpp
1>E:\Desktop\Coding\Test\main.cpp(45,28): error C2678: binary '==': no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\guiddef.h(192,15): message : could be 'bool operator ==(const GUID &,const GUID &)'
1>D:\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\include\random(2056,24): message : or 'bool std::operator ==(const std::bernoulli_distribution &,const std::bernoulli_distribution &)'
1>E:\Desktop\Coding\Test\main.cpp(45,28): message : or 'built-in C++ operator==(WCHAR [260], WCHAR [260])'
1>E:\Desktop\Coding\Test\main.cpp(45,28): message : while trying to match the argument list '(std::string, WCHAR [260])'
1>E:\Desktop\Coding\Test\main.cpp(106,24): warning C4305: 'argument': truncation from '__int64' to 'DWORD'
1>E:\Desktop\Coding\Test\main.cpp(106,9): warning C4309: 'argument': truncation of constant value
1>E:\Desktop\Coding\Test\main.cpp(111,27): warning C4305: 'argument': truncation from '__int64' to 'DWORD'
1>E:\Desktop\Coding\Test\main.cpp(111,9): warning C4309: 'argument': truncation of constant value
1>E:\Desktop\Coding\Test\main.cpp(133,23): warning C4305: 'argument': truncation from '__int64' to 'DWORD'
1>E:\Desktop\Coding\Test\main.cpp(133,9): warning C4309: 'argument': truncation of constant value
1>E:\Desktop\Coding\Test\main.cpp(137,24): warning C4305: 'argument': truncation from '__int64' to 'DWORD'
1>E:\Desktop\Coding\Test\main.cpp(137,9): warning C4309: 'argument': truncation of constant value
1>Done building project "Test.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
I'm using Unicode Char Set
I don't know if there is a more detailed log for the build. If there is, tell me where I can find it.

You are compiling the project with Unicode, so Process32FirstW() will be called instead of Process32First(). Change your function to take wstring as parameter or convert name to wstring before comparison:
std::wstring wName(name.begin(), name.end());
if (pe->szExeFile == wName) {

Use "wcscmp()" to compare your "wchar*" variables
if (!wcscmp(pe->szExeFile, wName))
{}

Related

binary '>=': 'std::chrono::system_clock::time_point'

I am not sure how to get ride of this compiler error:
error C2676: binary '>=': 'std::chrono::system_clock::time_point'
#include <ctime>
#include <chrono>
int main()
{
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
std::time_t now_c = std::chrono::system_clock::to_time_t(now - std::chrono::hours(24));
if (std::chrono::system_clock::now() >= now_c)
{
}
}
Here is what the compiler outputs:
1>------ Build started: Project: test, Configuration: Debug x64 ------
1> Source.cpp
1>d:\dev\cpptests\test\test\source.cpp(25): error C2784: 'bool std::operator >=(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)': could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'std::chrono::system_clock::time_point'
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\utility(311): note: see declaration of 'std::operator >='
1>d:\dev\cpptests\test\test\source.cpp(25): error C2784: 'bool std::chrono::operator >=(const std::chrono::duration<_Rep,_Period> &,const std::chrono::duration<_Rep2,_Period2> &)': could not deduce template argument for 'const std::chrono::duration<_Rep,_Period> &' from 'std::chrono::system_clock::time_point'
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\chrono(538): note: see declaration of 'std::chrono::operator >='
1>d:\dev\cpptests\test\test\source.cpp(25): error C2784: 'bool std::chrono::operator >=(const std::chrono::time_point<_Clock,_Duration> &,const std::chrono::time_point<_Clock,_Duration2> &)': could not deduce template argument for 'const std::chrono::time_point<_Clock,_Duration2> &' from 'time_t'
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\chrono(905): note: see declaration of 'std::chrono::operator >='
1>d:\dev\cpptests\test\test\source.cpp(25): error C2676: binary '>=': 'std::chrono::system_clock::time_point' does not define this operator or a conversion to a type acceptable to the predefined operator
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I recommend you to use type deduction with auto for this kind of case, as it makes the code much clearer. Also, as said in the comments above, the std::chrono facilities are not directly compatible with c-style time_t. I would recommend to keep using just std::chrono since it is more type-safe than it's counterpart.
#include <ctime>
#include <chrono>
#include <iostream>
int main()
{
auto now = std::chrono::system_clock::now();
auto now_c = now - std::chrono::hours(24);
if (std::chrono::system_clock::now() >= now_c)
{
std::cout << "it works!" << std::endl;
}
return 0;
}
You are try to compare a C++ time_point with a C time! And there is no operator >= to compare. Then you try to compare nanosecond with second
The time_point has a function named time_since_epoch and you can use it.
Using auto can help solve the problem but not understanding what happens and what is under the hood!
So you simply can compare(not good):
if ( now.time_since_epoch().count() >= now_c)
And the better code is:
std::chrono::duration_cast< std::chrono::seconds>(now.time_since_epoch()).count()
Because time_t is per second
if ( now.time_since_epoch().count() >= now_c){
std::cout << now.time_since_epoch().count() << '\n';
std::cout << std::chrono::duration_cast< std::chrono::seconds>(now.time_since_epoch()).count() << '\n';
std::cout << now_c << '\n';
}
the output:
1487879248873636085
1487879248
1487792848

Boost mpi x64 warning "size_t to int"

I have built Boost with mpi successfully, but I got lots of warnings using boost mpi under x64 platform. I am using Boost 1.59.0 + vs2015. Please help me get rid of these warnings
Here's my test code.
#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
#include <iostream>
namespace mpi = boost::mpi;
int main(int argc, char* argv[]) {
mpi::environment env(argc, argv);
mpi::communicator world;
std::cout << "I am process " << world.rank() << " of " << world.size()
<< "." << std::endl;
return 0;
}
And some of the warnings look like this:
1>d:\dependencies\boost_1_59_0\boost\mpi\detail\mpi_datatype_primitive.hpp(61) : warning C4267 : 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>d:\dependencies\boost_1_59_0\boost\mpi\detail\mpi_datatype_primitive.hpp(80) : warning C4267 : 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>d:\dependencies\boost_1_59_0\boost\mpi\detail\packed_iprimitive.hpp(62) : warning C4267 : 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>d:\dependencies\boost_1_59_0\boost\mpi\detail\packed_iprimitive.hpp(106) : warning C4267 : 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>d:\dependencies\boost_1_59_0\boost\mpi\detail\binary_buffer_iprimitive.hpp(64) : warning C4267 : 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>d:\dependencies\boost_1_59_0\boost\mpi\detail\packed_oprimitive.hpp(52) : warning C4267 : 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>d:\dependencies\boost_1_59_0\boost\mpi\detail\packed_oprimitive.hpp(96) : warning C4267 : “初始化” : conversion from 'size_t' to 'int', possible loss of data
1>d:\dependencies\boost_1_59_0\boost\mpi\detail\packed_oprimitive.hpp(100) : warning C4267 : 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>d:\dependencies\boost_1_59_0\boost\mpi\detail\binary_buffer_oprimitive.hpp(53) : warning C4267 : 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>d:\dependencies\boost_1_59_0\boost\mpi\detail\binary_buffer_oprimitive.hpp(87) : warning C4267 : 'argument' : conversion from 'size_t' to 'int', possible loss of data
1> d:\dependencies\boost_1_59_0\boost\archive\detail\oserializer.hpp(88) : note : see reference to function template instantiation'void boost::mpi::binary_buffer_oprimitive::save<char>(const std::basic_string<char, std::char_traits<char>, std::allocator<char>> &)'
1> d:\dependencies\boost_1_59_0\boost\archive\detail\oserializer.hpp(232) : note : see reference to function template instantiation 'void boost::archive::save_access::save_primitive<Archive, T>(Archive &, const T &)'
1> with
1>[
1> Archive = boost::mpi::packed_oarchive,
1> T = std::string
1>]
IMHO the MSVC C4267 warning is too sensitive. It even pops up when converting an int to a double. However, in this instance it may be valid, as #sjsam commented.
When I'm confident that the conversion is valid, I often disable the warning locally using:
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4244 ) // implicit conversion, possible loss of data
#endif
before the code, and re-enable it using:
#ifdef _MSC_VER
#pragma warning( pop )
#endif
If you are confident that the boost::mpi value will never exceed std::numeric_limits<int>::max() then put them around:
#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
so you can disable the C4267 warning for boost::mpi only.

Mex file in Matlab : error

I am trying to use SLIC superpixel matlab code.
The source code contains .c files. After using
mex -slicmex.c
The following errors appear :
slicmex.c
slicmex.c(108) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
slicmex.c(109) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
slicmex.c(123) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
slicmex.c(126) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
slicmex.c(171) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
slicmex.c(172) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
slicmex.c(173) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
slicmex.c(174) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
slicmex.c(386) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
slicmex.c(387) : error C2275: 'mwSize' : illegal use of this type as an expression
C:\Program Files\MATLAB\R2012a\extern\include\tmwtypes.h(792) : see declaration of 'mwSize'
slicmex.c(387) : error C2146: syntax error : missing ';' before identifier 'numdims'
slicmex.c(387) : error C2065: 'numdims' : undeclared identifier
slicmex.c(393) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
slicmex.c(445) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Compile of 'slicmex.c' failed.
Error using mex (line 206)
Unable to complete successfully.

Luatorrent compiling errors

I'm trying to build Luatorrent, a Lua module, it's quite old and really I just wanted to add one or two unfinished items to it but I can't get it to compile at all.
I'm using 'vintage' tools so I've got VS 2008 and boost 1.35.0.
I have added utils.h to the Header Files and torrent_session.cpp, torrent_info.cpp, torrent_handle.cpp and main.cpp to Source Files.
The following Pre-Processor Defines are added:
WIN32
_WINDOWS;
_USRDLL
WIN32_LEAN_AND_MEAN
_WIN32_WINNT=0x0500
BOOST_ALL_NO_LIB
_FILE_OFFSET_BITS=64
BOOST_THREAD_USE_LIB
UNICODE
TORRENT_USE_OPENSSL
NDEBUG
The following Additional Dependencies are compiled, without error, and added:
libboost_system-vc90-mt-1_35.lib
libboost_filesystem-vc90-mt-1_35.lib
libboost_date_time-vc90-mt-1_35.lib
libboost_thread-vc90-mt-1_35.lib
lua51.lib
libeay32.lib
ssleay32.lib
The following Additional Include Header Files are added:
C:\Client\boost-1_35_0\
C:\Client\libtorrent\include\
C:\Client\libtorrent\include\libtorrent\
C:\Client\libtorrent\zlib\
C:\Client\OpenSSL\include\
PCH support is disabled and according to the ReadMe with that done it should compile without errors but it never instead it threw 12 errors and 17 warnings, as far as I can tell the warnings are OK to ignore but the errors are what I need help with, here is the log:
1>------ Build started: Project: Client, Configuration: Release Win32 ------
1>Compiling...
1>torrent_session.cpp
1>C:\Client\libtorrent-0.12\include\libtorrent/session.hpp(86) : warning C4535: calling _set_se_translator() requires /EHa
1>..\..\..\..\..\..\..\Client\Client Source\torrent_session.cpp(107) : error C2664: 'libtorrent::torrent_handle libtorrent::session::add_torrent(const libtorrent::torrent_info &,const boost::filesystem::path &,const libtorrent::entry &,bool,int)' : cannot convert parameter 1 from 'boost::intrusive_ptr<T>' to 'const libtorrent::torrent_info &'
1> with
1> [
1> T=libtorrent::torrent_info
1> ]
1> Reason: cannot convert from 'boost::intrusive_ptr<T>' to 'const libtorrent::torrent_info'
1> with
1> [
1> T=libtorrent::torrent_info
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>..\..\..\..\..\..\..\Client\Client Source\torrent_session.cpp(109) : error C2664: 'libtorrent::torrent_handle libtorrent::session::add_torrent(const libtorrent::torrent_info &,const boost::filesystem::path &,const libtorrent::entry &,bool,int)' : cannot convert parameter 1 from 'boost::intrusive_ptr<T>' to 'const libtorrent::torrent_info &'
1> with
1> [
1> T=libtorrent::torrent_info
1> ]
1> Reason: cannot convert from 'boost::intrusive_ptr<T>' to 'const libtorrent::torrent_info'
1> with
1> [
1> T=libtorrent::torrent_info
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>..\..\..\..\..\..\..\Client\Client Source\torrent_session.cpp(112) : error C2664: 'libtorrent::torrent_handle libtorrent::session::add_torrent(const libtorrent::torrent_info &,const boost::filesystem::path &,const libtorrent::entry &,bool,int)' : cannot convert parameter 1 from 'boost::intrusive_ptr<T>' to 'const libtorrent::torrent_info &'
1> with
1> [
1> T=libtorrent::torrent_info
1> ]
1> Reason: cannot convert from 'boost::intrusive_ptr<T>' to 'const libtorrent::torrent_info'
1> with
1> [
1> T=libtorrent::torrent_info
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>..\..\..\..\..\..\..\Client\Client Source\torrent_session.cpp(180) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Integer', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_session.cpp(181) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Integer', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_session.cpp(182) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Integer', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_session.cpp(183) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Integer', possible loss of data
1>torrent_handle.cpp
1>C:\Client\libtorrent-0.12\include\libtorrent/session.hpp(86) : warning C4535: calling _set_se_translator() requires /EHa
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(52) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Number', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(53) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Number', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(54) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Integer', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(55) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Integer', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(56) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Number', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(57) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Number', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(80) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Integer', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(81) : warning C4244: 'argument' : conversion from 'libtorrent::size_type' to 'lua_Integer', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(451) : warning C4244: 'argument' : conversion from 'const libtorrent::size_type' to 'lua_Integer', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(452) : warning C4244: 'argument' : conversion from 'const libtorrent::size_type' to 'lua_Integer', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(470) : warning C4244: 'argument' : conversion from 'const libtorrent::size_type' to 'lua_Integer', possible loss of data
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(479) : error C2039: 'peer_source_flags' : is not a member of 'libtorrent::peer_info'
1> C:\Client\libtorrent-0.12\include\libtorrent/peer_info.hpp(46) : see declaration of 'libtorrent::peer_info'
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(537) : error C2039: 'upload_limit' : is not a member of 'libtorrent::torrent_handle'
1> C:\Client\libtorrent-0.12\include\libtorrent/torrent_handle.hpp(216) : see declaration of 'libtorrent::torrent_handle'
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(552) : error C2039: 'download_limit' : is not a member of 'libtorrent::torrent_handle'
1> C:\Client\libtorrent-0.12\include\libtorrent/torrent_handle.hpp(216) : see declaration of 'libtorrent::torrent_handle'
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(575) : error C2039: 'piece_priority' : is not a member of 'libtorrent::torrent_handle'
1> C:\Client\libtorrent-0.12\include\libtorrent/torrent_handle.hpp(216) : see declaration of 'libtorrent::torrent_handle'
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(577) : error C2039: 'piece_priority' : is not a member of 'libtorrent::torrent_handle'
1> C:\Client\libtorrent-0.12\include\libtorrent/torrent_handle.hpp(216) : see declaration of 'libtorrent::torrent_handle'
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(608) : error C2039: 'prioritize_pieces' : is not a member of 'libtorrent::torrent_handle'
1> C:\Client\libtorrent-0.12\include\libtorrent/torrent_handle.hpp(216) : see declaration of 'libtorrent::torrent_handle'
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(624) : error C2039: 'piece_priorities' : is not a member of 'libtorrent::torrent_handle'
1> C:\Client\libtorrent-0.12\include\libtorrent/torrent_handle.hpp(216) : see declaration of 'libtorrent::torrent_handle'
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(659) : error C2039: 'prioritize_files' : is not a member of 'libtorrent::torrent_handle'
1> C:\Client\libtorrent-0.12\include\libtorrent/torrent_handle.hpp(216) : see declaration of 'libtorrent::torrent_handle'
1>..\..\..\..\..\..\..\Client\Client Source\torrent_handle.cpp(674) : error C2039: 'scrape_tracker' : is not a member of 'libtorrent::torrent_handle'
1> C:\Client\libtorrent-0.12\include\libtorrent/torrent_handle.hpp(216) : see declaration of 'libtorrent::torrent_handle'
1>Build log was saved at "file://c:\Users\User\Documents\Visual Studio 2008\Projects\Client\Client\Release\BuildLog.htm"
1>Client - 12 error(s), 17 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Error 1 references this [th = s->add_torrent(t, path, e)], error 2 and 3 are the same error code:
static int torrent_session_add_torrent(lua_State *L) {
int n = lua_gettop(L);
void* ud = 0;
ud = luaL_checkudata(L, 1, "Torrent.Session");
session *s = *((session **)ud);
ud = luaL_checkudata(L, 2, "Torrent.Info");
torrent_info *ti = *((torrent_info **)ud);
boost::intrusive_ptr<torrent_info> t(ti);
try {
torrent_handle th;
if (n >= 3 && !lua_isnil(L, 3)) {
const char *path = "./";
if (!lua_isnil(L, 3)) {
path = luaL_checkstring(L, 3);
}
if (n == 4 && !lua_isnil(L, 4)) {
const char *filename = luaL_checkstring(L, 4);
std::ifstream in(filename, std::ios_base::binary);
in.unsetf(std::ios_base::skipws);
entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
th = s->add_torrent(t, path, e);
} else {
th = s->add_torrent(t, path);
}
} else {
th = s->add_torrent(t, "./");
}
torrent_handle **h = (torrent_handle **)lua_newuserdata(L, sizeof(torrent_handle *));
*h = new torrent_handle(th);
luaL_getmetatable(L, "Torrent.Handle");
lua_setmetatable(L, -2);
} catch (std::exception& e) {
luaL_error(L, "%s", e.what());
lua_pushnil(L);
}
return 1;
}
All the other errors reference this in torrent_handle.cpp where its believed the returned table items are not a member of 'libtorrent::torrent_handle':
static int torrent_handle_get_peer_info(lua_State *L) {
void* ud = 0;
ud = luaL_checkudata(L, 1, "Torrent.Handle");
torrent_handle *h = *((torrent_handle **)ud);
std::vector<peer_info> peers;
h->get_peer_info(peers);
int c = 1;
lua_newtable(L);
for (std::vector<peer_info>::const_iterator i = peers.begin(); i != peers.end(); ++i) {
lua_pushinteger(L, c);
lua_newtable(L);
LUA_PUSH_ATTRIB_INT("flags", i->flags);
std::ostringstream out;
out << i->ip;
LUA_PUSH_ATTRIB_STRING("ip", out.str().c_str());
LUA_PUSH_ATTRIB_FLOAT("up_speed", i->up_speed);
LUA_PUSH_ATTRIB_FLOAT("down_speed", i->down_speed);
LUA_PUSH_ATTRIB_FLOAT("payload_up_speed", i->payload_up_speed);
LUA_PUSH_ATTRIB_FLOAT("payload_down_speed", i->payload_down_speed);
LUA_PUSH_ATTRIB_INT("total_download", i->total_download);
LUA_PUSH_ATTRIB_INT("total_upload", i->total_upload);
//pid
//pieces
std::vector<bool> pieces = i->pieces;
lua_pushstring(L, "pieces");
lua_newtable(L);
int d = 1;
for (std::vector<bool>::const_iterator b = pieces.begin(); b != pieces.end(); ++b) {
LUA_PUSH_ARRAY_BOOL(d, *b);
}
lua_settable(L, -3);
LUA_PUSH_ATTRIB_BOOL("seed", i->seed);
LUA_PUSH_ATTRIB_INT("upload_limit", i->upload_limit);
LUA_PUSH_ATTRIB_INT("download_limit", i->download_limit);
LUA_PUSH_ATTRIB_STRING("country", i->country);
LUA_PUSH_ATTRIB_INT("load_balancing", i->load_balancing);
LUA_PUSH_ATTRIB_INT("download_queue_length", i->download_queue_length);
LUA_PUSH_ATTRIB_INT("upload_queue_length", i->upload_queue_length);
LUA_PUSH_ATTRIB_INT("downloading_piece_index", i->downloading_piece_index);
LUA_PUSH_ATTRIB_INT("downloading_block_index", i->downloading_block_index);
LUA_PUSH_ATTRIB_INT("downloading_progress", i->downloading_progress);
LUA_PUSH_ATTRIB_INT("downloading_total", i->downloading_total);
LUA_PUSH_ATTRIB_STRING("client", i->client.c_str());
LUA_PUSH_ATTRIB_INT("connection_type", i->connection_type);
LUA_PUSH_ATTRIB_INT("peer_source_flags", i->peer_source_flags);
lua_settable(L, -3);
c++;
}
return 1;
}
I have a precomputed dll so I know the code does work but obviously without being able to rebuild it I cant add the extra features I need.

What is the meaning of compiler error message "Polygon is ambigious"

I'm trying to declare an object in c++:
Polygon poly;
and the compiler is telling that that "Polygon is ambigious". What does that mean?
Here is the full code:
#include "Graph.h"
#include "Simple_window.h"
#include "point.h"
#include "Window.h"
using namespace Graph_lib;
int main(int argc, char **argv)
{
Point tl(100,100);
Simple_window win(tl,600,400,"canvas");
Axis xa(Axis::x, Point(20,300),280 ,10, "x axis");
win.attach(xa);
win.set_label("canvas #2");
win.wait_for_button();
Axis ya(Axis::y, Point(20,300),280 ,10, "y axis");
ya.set_color(Color::cyan);
ya.label.set_color(Color::dark_red);
win.attach(ya);
win.set_label("canvas #3");
win.wait_for_button();
Function sine(sin,0,100, Point(20,150),1000,50,50);
win.attach(sine);
win.set_label("canvas #4");
win.wait_for_button();
sine.set_color(Color::blue);
Polygon poly; ///ERROR! Ambigious!!!
poly.add(Point(300,200));
poly.add(Point(350,100));
poly.add(Point(400,200));
poly.set_color(Color::red);
poly.set_style(Line_style::dash);
win.attach(poly);
win.set_label("canvas #5");
win.wait_for_button();
}
As you can see there's a conflict between the user written header, and some header included some where. This is after have recently installed FLTK 1.3.
1>------ Build started: Project: test, Configuration: Debug Win32 ------
1> Graph.cpp
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.cpp(65): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.cpp(131): warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.cpp(132): warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.cpp(389): warning C4800: 'void *' : forcing value to bool 'true' or 'false' (performance warning)
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.cpp(414): warning C4018: '>=' : signed/unsigned mismatch
1> GUI.cpp
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(107): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(112): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(117): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130): warning C4018: '<' : signed/unsigned mismatch
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130) : while compiling class template member function 'Graph_lib::Vector_ref<T>::~Vector_ref(void)'
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(99) : see reference to class template instantiation 'Graph_lib::Vector_ref<T>' being compiled
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> Simple_window.cpp
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(107): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(112): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(117): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130): warning C4018: '<' : signed/unsigned mismatch
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130) : while compiling class template member function 'Graph_lib::Vector_ref<T>::~Vector_ref(void)'
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(99) : see reference to class template instantiation 'Graph_lib::Vector_ref<T>' being compiled
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> test.cpp
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(107): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(112): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(117): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(36): error C2872: 'Polygon' : ambiguous symbol
1> could be 'c:\program files (x86)\microsoft sdks\windows\v7.0a\include\wingdi.h(4548) : BOOL Polygon(HDC,const POINT *,int)'
1> or 'c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(256) : Graph_lib::Polygon'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(36): error C2872: 'Polygon' : ambiguous symbol
1> could be 'c:\program files (x86)\microsoft sdks\windows\v7.0a\include\wingdi.h(4548) : BOOL Polygon(HDC,const POINT *,int)'
1> or 'c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(256) : Graph_lib::Polygon'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(36): error C2146: syntax error : missing ';' before identifier 'poly'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(36): warning C4551: function call missing argument list
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(36): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(37): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(37): error C2228: left of '.add' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(38): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(38): error C2228: left of '.add' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(39): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(39): error C2228: left of '.add' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(41): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(41): error C2228: left of '.set_color' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(42): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(42): error C2228: left of '.set_style' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(43): error C2065: 'poly' : undeclared identifier
1> Window.cpp
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(107): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(112): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(117): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\window.cpp(74): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\window.cpp(76): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130): warning C4018: '<' : signed/unsigned mismatch
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130) : while compiling class template member function 'Graph_lib::Vector_ref<T>::~Vector_ref(void)'
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(99) : see reference to class template instantiation 'Graph_lib::Vector_ref<T>' being compiled
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It means that you've declared two or more entities (types, functions, variables, etc.) called Polygon, and the compiler can't tell which you mean in this context.
The complete error message should tell you which declarations are causing the ambiguity. Without seeing them, it's hard to guess how best to fix the error.
UPDATE: Now you've posted some code, but not the complete error message or the problematic declarations, I'll hazard a guess that Polygon is declared in both the global and Graph_lib namespaces. You then dump the whole of Graph_lib into the global namespace, making the name ambiguous. If this is the case, then you'll need to specify ::Polygon or Grapg_lib::Polygon to resolve the ambiguity.
because there also have a Polygon defined in wingdi.h
THE SOLUTION IS Put NOGDI in preprocessor. In Visual Studio Project Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions -> add NOGDI.