Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows MSVC c++20 apps fail to compile due to depthai nop variant fail #407

Closed
diablodale opened this issue Feb 26, 2022 · 3 comments
Closed
Assignees

Comments

@diablodale
Copy link
Contributor

diablodale commented Feb 26, 2022

WIndows app compiles fail in depthai-core headers on MSVC, c++20 standard, and the non-conformant preprocessor.
This is building a main app (e.g the tests)...not depthai-core itself. Depthai-core was built c++14 as usual.

when adjusting cmake to compile tests/serialization_test in c++14, 17, and 20...
14 and 17, with conformant and non-conformant preprocessor compiles
20 conformant preprocessor compile fail 👎
20 non-conformant preprocessor compile fail 👎

Setup

  • Microsoft Windows [Version 10.0.19044.1526]
  • VS2019 v16.11.10
  • depthai-core develop 3a2961d

Repro

  1. Adjust tests/CMakefile.txt so that you compile tests with 14, 17, and 20
  2. Fix bug in tests/CMakefile.txt so it sets the preprocessor flags using PRIVATE (I recommend) or PUBLIC not the errant INTERFACE. e.g. target_compile_options(${test_name}_conforming PRIVATE "/Zc:preprocessor")
  3. cmake config. Confirm (fix step 2) the preprocessor flags are on the compiles for conformant tests
  4. cmake build

Result

The compile of tests for C++20 compile fail with same errors. Here is attempt to build serialization_test...

[main] Building folder: depthai-core filesystem_test_20_conforming
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.exe" --build c:/njs/depthai-core/build --config Debug --target filesystem_test_20_conforming -j 14 --
[build] [1/2  50% :: 7.647] Building CXX object tests\CMakeFiles\filesystem_test_20_conforming.dir\src\filesystem_test.cpp.obj
[build] FAILED: tests/CMakeFiles/filesystem_test_20_conforming.dir/src/filesystem_test.cpp.obj 
[build] C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe  /nologo /TP -DBLOB_PATH=\"C:/.hunter/_Base/PrivateData/3329bb8f3a9c881ef9756d232055f9d6f38aa07b/3329bb8/raw/mobilenet-ssd_openvino_2021.2_8shave.blob\" -DDEPTHAI_TARGET_CORE -DJSON_USE_IMPLICIT_CONVERSIONS=1 -DXLINK_USE_MX_ID_NAME=ON -D__PC__ -Dfilesystem_test_20_conforming_EXPORTS -IC:\njs\vcpkg\installed\x64-windows-static-md-v142-sdk10\include -I..\include -I..\shared\depthai-shared\include -I..\shared\depthai-bootloader-shared\include -I..\shared\depthai-shared\3rdparty -IC:\.hunter\_Base\9b4e732\9daff0d\036e6a8\Install\include -DWINVER=0x0A00 -D_WIN32_WINNT=0x0A00 -DNTDDI_VERSION=0x0A000005 /arch:AVX /Gw /QIntel-jcc-erratum /guard:cf /GS  -D_CRT_SECURE_NO_WARNINGS /wd5030 /w15240 -D_CRT_SECURE_NO_WARNINGS /wd5030 /w15240   /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 -DNOMINMAX /Zc:preprocessor -std:c++20 /showIncludes /Fotests\CMakeFiles\filesystem_test_20_conforming.dir\src\filesystem_test.cpp.obj /Fdtests\CMakeFiles\filesystem_test_20_conforming.dir\ /FS -c ..\tests\src\filesystem_test.cpp
[build] C:\.hunter\_Base\9b4e732\9daff0d\036e6a8\Install\include\nop/types/variant.h(294): error C2760: syntax error: unexpected token '...', expected ')'
[build] C:\.hunter\_Base\9b4e732\9daff0d\036e6a8\Install\include\nop/types/variant.h(292): note: This diagnostic occurred in the compiler generated function 'bool nop::IfAnyOf<ValidTypes...>::Call(nop::Variant<Types...> *,Op &&)'
[build] C:\.hunter\_Base\9b4e732\9daff0d\036e6a8\Install\include\nop/types/variant.h(351): note: see reference to class template instantiation 'nop::IfAnyOf<ValidTypes...>' being compiled
[build] C:\.hunter\_Base\9b4e732\9daff0d\036e6a8\Install\include\nop/types/variant.h(301): error C2760: syntax error: unexpected token '...', expected ')'
[build] C:\.hunter\_Base\9b4e732\9daff0d\036e6a8\Install\include\nop/types/variant.h(299): note: This diagnostic occurred in the compiler generated function 'bool nop::IfAnyOf<ValidTypes...>::Call(const nop::Variant<Types...> *,Op &&)'
[build] ninja: build stopped: subcommand failed.
[build] Build finished with exit code 1

Expected

clean build, no errors, tests pass

@diablodale diablodale changed the title Windows app compiles fail in depthai headers on MSVC with c++20 and non-conformant preprocessor Windows MSVC c++20 apps fail to compile due to depthai nop variant fail Feb 26, 2022
diablodale added a commit to diablodale/depthai-core that referenced this issue Feb 27, 2022
diablodale added a commit to diablodale/depthai-core that referenced this issue Feb 27, 2022
- unable to fully test due to bug luxonis#407
@Bercon
Copy link

Bercon commented Feb 28, 2022

I also ran into this issue. Do you happen to know any good workarounds that could work in the mean time?

@diablodale
Copy link
Contributor Author

I don't. The headers are used by depthai-core and by consuming apps. I believe the issue has to be investigated in those shared headers. C++20 seems to be off-limits for now.

diablodale added a commit to diablodale/depthai-core that referenced this issue Mar 4, 2022
- unable to fully test due to bug luxonis#407
@themarpe themarpe self-assigned this Mar 12, 2022
themarpe pushed a commit that referenced this issue Apr 9, 2022
* initial dai::Path and test cases

- fixes #352

* move codecvt from header -> cpp

* add Path::string() and u8string()

- to enable display/log of Path

* fmt for dai::Path; NN::setBlobPath(dai::Path)

* dia::path throws like std::fs::path

* c++17, pub/pvt header, test cmake c++ std level

- enable c++17 std::filesystem support and test cases
- split header into public/private parts
- cmake for test cases now supports optional
  c++ standard level param

* verify c++ std compiler support for tests

- add COMPILER_SUPPORTS_CXX{14,17,20,23} vars
  to Flags.cmake and can be used everywhere

* add dai::Path::empty()

* add dai::Path to Device, DeviceBase, Resources

- simplify Device, DeviceBase constructors by delegating
- add is_same<> template on constructors with bool param to
  prevent implicit convert of almost everything to bool
- make two DeviceInfo constructors explicit to prevent their use in
  implicit conversion
- relevant test cases
- fix minor throw text bugs

* fix Device usb2Mode sigs, add test case

* add dai::Path to CalibrationHandler

* minor refactor dai::Path

* enable 2 Calibration+1 Bootloader example

* add dai::Path to DeviceBootloader, XLinkConnection

- plus test cases

* add dai::Path to Pipeline, StereoDepth, AssetManager

- plus test cases

* add dai::Path to dai::Script + test cases

* linux fixes for test cases, and c++14 type_traits

* add doxygen to dai::Path

* detect compiler c++ std level and update cmake

* fix preprocessor flag for tests on MSVC

- fixes luxonis/depthai-core/issues#408

* partial dai::Path support for c++20 utf-8

- unable to fully test due to bug #407

* add windows header define WIN32_LEAN_AND_MEAN

* rename macro to DEPTHAI_NODISCARD

- review feedback
@themarpe themarpe mentioned this issue Apr 9, 2022
@themarpe
Copy link
Collaborator

Fixed in #448 @Bercon @diablodale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants