Asio Compiler errors (Win7 64 Bit + VC11) - c++

a few days ago I upgraded from Win7 32Bit + Visual Studio 2008 to Win7 64Bit + Visual Studio 2012 (VC11). Now I have problems with compiling my application. I get the following errors:
1>...\asio-1.5.3\include\asio/detail/impl/win_thread.ipp(51): error C2664: 'QueueUserAPC': cannot convert parameter 1 from 'void (__cdecl *)(ULONG)' to 'PAPCFUNC'
1>...\asio-1.5.3\include\asio/detail/impl/win_iocp_io_service.ipp(119): error C2664: 'GetQueuedCompletionStatus': cannot convert parameter 3 from 'DWORD *' to 'PULONG_PTR'
1>...\asio-1.5.3\include\asio/detail/impl/win_iocp_io_service.ipp(349): error C2664: 'GetQueuedCompletionStatus': cannot convert parameter 3 from 'DWORD *' to 'PULONG_PTR'
And I get the same errors with the latest version of boost::asio (Boost 1.52)
What’s wrong here?

with WINVER set to 0x0501 it's working - Many Thanks to Hans Passant for his hint!

Related

What the underlying reason C code will compile using mingw32 in Linux but Visual Studio C has problems

So Im wondering why C code compiled for me with mingw32 (this program here fo reference https://github.com/newsoft/adduser) with no issues or mentions of errors (other than some case-sensitivity in naming of the headers i mean)
Though, when I tried in Visual Studio 2019 I get the following "errors" that need to be cleaned up.
Error C2440 '=': cannot convert from 'const wchar_t [15]' to 'LPWSTR' adduser-test2 C:\Users\Administrator\source\repos\adduser-test\adduser-test2\adduser-test2.cpp 39
Error C2440 '=': cannot convert from 'const wchar_t [6]' to 'LPWSTR' adduser-test2 C:\Users\Administrator\source\repos\adduser-test\adduser-test2\adduser-test2.cpp 38
Is it some sort of strict compiler settings for "safer code"? Or is one compiler actually just able to convert a const wchar_t could convert to a pointer to a wchar_t if necessary

errors C2784, C2672 and C2664 in Visual studio 2015

I have following lines in visual studio 2015. It used to be compiled without error in visual studio 2013.
const std::basic_regex<wchar_t> e(_T("([eE][-+])(0)(\\d{2})"));
io_string = std::regex_replace(io_string, e, _T("$1$3"));
the error is:
error C2664: 'std::basic_regex>::basic_regex(std::basic_regex> &&) noexcept': cannot convert argument 1 from 'const char [21]' to 'const wchar_t *'
error C2672: 'std::regex_replace': no matching overloaded function found
4>
error C2784: 'std::basic_string<_Elem,std::char_traits<_Elem>,std::allocator<_Other>> std::regex_replace(const _Elem *,const std::basic_regex<_Elem,_RxTraits> &,const _Elem *,std::regex_constants::match_flag_type)': could not deduce template argument for 'const _Elem *' from 'std::string_t'
I know this issue is coming from change tchar.h. Any suggestion for resolving them. I also use CMake for project configuration and the project is running on windows 10.
Assuming you don't want to change your code, you need to ensure that your code is building for Unicode, so pass -D_UNICODE to the compiler. This post suggests:
ADD_DEFINITIONS(-DUNICODE)
ADD_DEFINITIONS(-D_UNICODE)
And this one illustrates how to enable Unicode through the GUI.

Visual Studio 2013 - C++ Errors

Some strange things happen. When I compile my program in Dev-C++ it gives me no errors and compiles clean. When I put it in Visual Studio I got a LOT of errors:
Error 1 error C2371: 'MailRecipient' : redefinition; different basic types
Error 2 error C3861: 'GetModuleFileName': identifier not found
Error 3 error C2664: 'HRESULT SHGetFolderPathW(HWND,int,HANDLE,DWORD,LPWSTR)' : cannot convert argument 5 from 'char [260]' to 'LPWSTR'
Error 4 error C3861: 'CopyFile': identifier not found
Error 5 error C2664: 'BOOL SetFileAttributesW(LPCWSTR,DWORD)' : cannot convert argument 1 from 'char [512]' to 'LPCWSTR'
Error 6 error C2664: 'HRESULT SHGetFolderPathW(HWND,int,HANDLE,DWORD,LPWSTR)' : cannot convert argument 5 from 'char [260]' to 'LPWSTR'
Error 7 error C2664: 'BOOL SetFileAttributesW(LPCWSTR,DWORD)' : cannot convert argument 1 from 'char []' to 'LPCWSTR'
Error 8 error C2664: 'LSTATUS RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY)' : cannot convert argument 2 from 'const char [46]' to 'LPCWSTR'
Error 9 error C2664: 'HRESULT SHGetFolderPathW(HWND,int,HANDLE,DWORD,LPWSTR)' : cannot convert argument 5 from 'char [260]' to 'LPWSTR'
Error 10 error C2664: 'LSTATUS RegSetValueExW(HKEY,LPCWSTR,DWORD,DWORD,const BYTE *,DWORD)' : cannot convert argument 2 from 'const char [9]' to 'LPCWSTR'
It all works on Dev-C++ tho. I need to compile it in VS because I want to add something from the POCO library, which, ironically, doesn't compile in Dev-C++... Any help?
A Visual Studio project defines UNICODE by default.
You can either turn off Unicode in the project settings, or rework your program to use wchar_t based strings (e.g. L"Blah" instead of "Blah").
Or, you can #undef UNICODE before including <windows.h>, every place.
There seem to be some issues about #include statements in your Project. You need to figure out why MailRecipient gets redefined. You will probably have to adjust some of the project settings in Visual Studio. Also, as the first answer suggests Visual Studio uses UNICODE by default, which causes it to call the wide string versions of Windows API functions. You can use the std::widen function to convert your strings just for Windows API calls. For more information on this topic see utf8everywhere.org.

c++ - Error compiling Anax with Visual Studio 2013

I recently motivate myself to code ECS way. So i download anax and tryed to compile it. Here is the problem, i only tryed and didn't achieved it. I generated the file for Visual Studio and upgraded msvc12 to latest version. But now i get this error and I have no idea how to fix it :
error C2664: 'void std::vector>::emplace_back(anax::Entity::Id::int_type &,unsigned __int64 &)' : cannot convert argument 1 from 'anax::Entity::Id::int_type' to 'anax::Entity::Id::int_type &'
And here is the code line which throws the error :
m_freeList.emplace_back(static_cast<Entity::Id::int_type>(id.index), counter);
Does someone has an idea how to fix this ?

Compiler warning in boost crc.hpp with Visual C++ (error C4244)

I am using boost/crc.hpp version 1.49 for crc calculation in Visual Studio 2013.
When I instantiate a variable of type
boost::crc_32_type
I get a compiler error
Error 7 error C4244: 'return' : conversion from 'unsigned int' to 'unsigned char', possible loss of data C:\boost_1_49_0_0\boost\crc.hpp 578 1 MyProgram
I found this ticket from over 5 years ago:
https://svn.boost.org/trac/boost/ticket/3194
Does anyone have an idea how to solve it? Do I have to patch crc.hpp?
My warning level is 4.
I am simply surpressing the warning now.
#pragma warning(disable: 4244)
#include <boost/crc.hpp>
#pragma warning(default: 4244)