Nodepp does not compile under MSVC (Visual Studio 2022, C++20, Windows x64). Three separate issues, each independent of the others. Happy to send a PR for all three if you'd like them.
1. include/nodepp/import.h includes <unistd.h> unconditionally.
<unistd.h> is POSIX-only and does not exist on MSVC, so the very first include fails. Guarding it is enough:
#ifndef _WIN32
#include <unistd.h>
#endif
2. include/nodepp/macros.h defines min, max and clamp as templates at global scope.
On Windows these collide with the min/max macros from <windows.h> (pulled in transitively by the Winsock headers the library itself needs), and they also conflict with std::min/std::max under ADL. Wrapping them in the nodepp namespace resolves it without changing behaviour for existing users:
namespace nodepp {
template< class T > T min( const T& a, const T& b ){ return a < b ? a : b; }
template< class T > T max( const T& a, const T& b ){ return a > b ? a : b; }
template< class T > T clamp( const T& v, const T& lo, const T& hi ){ return max( lo, min( hi, v ) ); }
}
3. _STRING_ is too generic a macro name and collides on Windows.
Renaming it avoids the collision:
#define NODEPP_STRINGIFY(...) #__VA_ARGS__
#define _JSON_(...) json::parse(NODEPP_STRINGIFY(__VA_ARGS__))
Also worth flagging: _FUNC_ is defined as __PRETTY_FUNCTION__, which MSVC does not provide (__FUNCSIG__ is the equivalent).
Tested against V1.4.0 and the current main (V1.5.0) — both fail identically.
Nodepp does not compile under MSVC (Visual Studio 2022, C++20, Windows x64). Three separate issues, each independent of the others. Happy to send a PR for all three if you'd like them.
1.
include/nodepp/import.hincludes<unistd.h>unconditionally.<unistd.h>is POSIX-only and does not exist on MSVC, so the very first include fails. Guarding it is enough:2.
include/nodepp/macros.hdefinesmin,maxandclampas templates at global scope.On Windows these collide with the
min/maxmacros from<windows.h>(pulled in transitively by the Winsock headers the library itself needs), and they also conflict withstd::min/std::maxunder ADL. Wrapping them in thenodeppnamespace resolves it without changing behaviour for existing users:3.
_STRING_is too generic a macro name and collides on Windows.Renaming it avoids the collision:
Also worth flagging:
_FUNC_is defined as__PRETTY_FUNCTION__, which MSVC does not provide (__FUNCSIG__is the equivalent).Tested against V1.4.0 and the current
main(V1.5.0) — both fail identically.