Lichtso / netLink

Socket and Networking Library using msgpack.org[C++11]
GNU General Public License v3.0
216 stars 48 forks source link

Building netLink in Visual Studio 2017 #24

Closed DJuego closed 7 years ago

DJuego commented 7 years ago

Hi! First; My sincere appreciation, Lichtso. During the last months I have worked frequently with your library, successfully. I have a few questions and stories for you. :-)

However now i want to declare a building problem with netLink in "Visual Studio 2017" (Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25019 for x64).

Microsoft (R) Program Maintenance Utility Version 14.10.25019.0
Copyright (C) Microsoft Corporation.  All rights reserved.

[  7%] Building CXX object CMakeFiles/shared.dir/src/Utf8.cpp.obj
Utf8.cpp
P:\Compilados\x32-x64\TRABAJO_MSVC2017_x64\netlink\include\Utf8.h(167): error C3861: '__lzcnt': identifier not found
P:\Compilados\x32-x64\TRABAJO_MSVC2017_x64\netlink\src\Utf8.cpp(88): note: see reference to function template instantiation 'char32_t utf8::toUtf32<std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>>(iterator)' being compiled
        with
        [
            iterator=std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>
        ]
P:\Compilados\x32-x64\TRABAJO_MSVC2017_x64\netlink\include\Utf8.h(167): error C2050: switch expression not integral
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~4\2017\ENTERP~1\VC\Tools\MSVC\1410~1.250\bin\Hostx64\x64\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\nmake.exe"' : return code '0x2'

Thanks in advance!

DJuego

P,S: No problem with Visual Studio 2015

Lichtso commented 7 years ago

Hi, try to add: #include <intrin.h> after Line 21 in include/Utf8.h: #ifdef _MSC_VER

if that does not work, try to replace __lzcnt by _BitScanReverse but you will have to change the macro into a function to handle the different return/param layout: https://msdn.microsoft.com/us-en/library/bb384809.aspx

DJuego commented 7 years ago

Yes, @Lichtso. I can confirm you that the fix (#include <intrin.h>) works. 👍 I think it's a good idea to update the repository with this little fix(IMHO)...

Sorry to bother you for this very small things... :-/ Thanks for your very very swift answers!

DJuego

Lichtso commented 7 years ago

No problem, you are welcome :)