hi Harris Thanks for reply Before all I forgot to show one more issue - i had to patch cap'n'proto sources: c++/src/kj/thread.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/c++/src/kj/thread.h b/c++/src/kj/thread.h index b17b88c..14f7a47 100644 --- a/c++/src/kj/thread.h +++ b/c++/src/kj/thread.h @@ -56,7 +56,12 @@ private: Function<void()> func; kj::Maybe<kj::Exception> exception; - unsigned int refcount; +#if _MSC_VER + volatile long refcount; +#else + unsigned int refcount; +#endif + // Owned by the parent thread and the child thread. void unref(); InterlockedDecrement expects volatile long среда, 5 июля 2017 г., 22:55:26 UTC+3 пользователь Harris Hancock написал: > > Hi Vitaliy, > > Thanks for the feedback on the MSVC build. I put a couple responses inline. > > On Wed, Jul 5, 2017 at 10:06 AM, Vitaliy Bondarchuk < > vitaliy.b...@gmail.com <javascript:>> wrote: > >> hi guys >> >> I switched to 0.6.1 and had to workaround 3 issues >> > > [snip macro and warning workaround code] > > Indeed, the min, max, VOID, etc. macros, and the gratuitous warnings > emitted by MSVC, are long-standing issues that would be great to get > resolved. I had hoped I'd have had time to fix them by now, but have been > caught up in work and now vacation. > > For warnings, the approach you outlined is the only complete solution I > can see to clean them up. > > For macros, we have a couple other options. `min` and `max` could be > parenthesized in Cap'n Proto code to prevent the preprocessor from > interpreting them as function-like macros. I believe this is common > practice among Windows programmers, though I didn't learn the trick until > recently. > > That leaves VOID and friends. Kenton has suggested converting them into > global-scope symbols, exemplified here: > > https://github.com/capnproto/capnproto/blob/master/c%2B%2B/src/kj/windows-sanity.h#L33 > > He wrote some rationale here: > https://groups.google.com/d/msg/capnproto/glQHUGVIlN0/an2htV_FAQAJ > > It feels weird to me to convert a foreign macro into a symbol, but after > thinking about it, I don't see any downside. Do you have an opinion either > way? > imho, MSVC push/pop solution is the best. if it applicable for you and Kenton - probably it would be best if the library will have main header like <capnproto.h> which will have this workaround inside (proto compiler may insert it into generated header). when you convert macro to constant it change nature. and it may have side effects. constant has: - exact type. i guess even if you use "auto" - constant will get "int" type. so in various assignments you may get a lot of data conversion warnings - it became entity with linkage. so by mistake you will be able to take address of this constants. and may be you may have issues with std::move semantics expressions > > 3. it looks like somewhy cmake doesn't include c++\src\kj\units.c++ into >> the static library. I got linking error. As workaround I just copy-pasted >> the piece of code from c++\src\kj\units.c++ to one of my cpp files and my >> binary liked successfully. >> > > This one is new to me. If possible, can you provide a minimal test case > that demonstrates the compile error, perhaps by modifying the code in > c++/samples to make it break? I'm on vacation for the next couple weeks, > but will look at it when I get home. > i will try to identity the reason of the issue, but now i have no idea why this happens. i use this bat file for compile static libraries for my project rmdir /S /Q _tlmdb32 rmdir /S /Q _tlmdb64 call :buildcmake _tlmdb32 "Visual Studio 15 2017" ..\c++ RelWithDebInfo _out\lib_rel32 call :buildcmake _tlmdb64 "Visual Studio 15 2017 Win64" ..\c++ RelWithDebInfo _out\lib_rel64 call :buildcmakedbg _tlmdb32 "Visual Studio 15 2017" ..\c++ Debug _out\lib_dbg32 call :buildcmakedbg _tlmdb64 "Visual Studio 15 2017 Win64" ..\c++ Debug _out\lib_dbg64 exit /b :buildcmake set buildfolder=%1 set builder=%2 set srcfolder=%3 set buildconfig=%4 set dstlib=%5 mkdir %buildfolder% pushd %buildfolder% mkdir _install cmake -G %builder% %srcfolder% -DCAPNP_LITE=1 -DEXTERNAL_CAPNP=1 -DCMAKE_GENERATOR_TOOLSET="v141_xp" -DCMAKE_VS_PLATFORM_TOOLSET="v141_xp" -DCMAKE_CONFIGURATION_TYPES="RelWithDebInfo" -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="/MT /Zi /O2 /Ob1 /D NDEBUG " -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="_install" popd cmake --build %buildfolder% --config %buildconfig% --target capnp mkdir %dstlib% xcopy /Y /S %buildfolder%\src\kj\RelWithDebInfo\*.lib %dstlib% xcopy /Y /S %buildfolder%\src\kj\kj.dir\RelWithDebInfo\*.pdb %dstlib% xcopy /Y /S %buildfolder%\src\capnp\RelWithDebInfo\*.lib %dstlib% xcopy /Y /S %buildfolder%\src\capnp\capnp.dir\RelWithDebInfo\*.pdb %dstlib% rmdir /S /Q %buildfolder% exit /b :buildcmakedbg set buildfolder=%1 set builder=%2 set srcfolder=%3 set buildconfig=%4 set dstlib=%5 mkdir %buildfolder% pushd %buildfolder% mkdir _install cmake -G %builder% %srcfolder% -DCAPNP_LITE=1 -DEXTERNAL_CAPNP=1 -DCMAKE_GENERATOR_TOOLSET="v141_xp" -DCMAKE_VS_PLATFORM_TOOLSET="v141_xp" -DCMAKE_CONFIGURATION_TYPES="Debug" -DCMAKE_CXX_FLAGS_DEBUG="/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1 " -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="_install" popd cmake --build %buildfolder% --config %buildconfig% --target capnp mkdir %dstlib% xcopy /Y /S %buildfolder%\src\kj\Debug\*.lib %dstlib% xcopy /Y /S %buildfolder%\src\kj\kj.dir\Debug\*.pdb %dstlib% xcopy /Y /S %buildfolder%\src\capnp\Debug\*.lib %dstlib% xcopy /Y /S %buildfolder%\src\capnp\capnp.dir\Debug\*.pdb %dstlib% rmdir /S /Q %buildfolder% exit /b The cmake I have is 3.8.2 and VS is "Microsoft Visual Studio 2017 Version 15.0.26228.4" by the way, as I see in aside thread probably you need to a helper pragma for linker #pragma comment(lib,"Ws2_32.lib") > Thanks, > Harris > > -- You received this message because you are subscribed to the Google Groups "Cap'n Proto" group. To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+unsubscr...@googlegroups.com. Visit this group at https://groups.google.com/group/capnproto.