Qualcomm AI Engine Direct - Support MSVC-compatible code#19686
Qualcomm AI Engine Direct - Support MSVC-compatible code#19686zhaoxul-qti wants to merge 1 commit into
Conversation
- Remove the designated initializers for C++
- Remove the GNU statement expressions
- Replace constexpr inside the lambda [&]
- Replace the __attribute__((visibility("default"))) with corresponding MSVC-compatible syntax
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19686
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below:
|
This PR needs a
|
|
This PR also fix the issue mentioned in 4b7bea2 |
Summary
1. Remove the designated initializers for C++
Why it compiles on Linux but not on Windows MSVC?
-std=c++17mode. MSVC is strictly conformant: it only accepts designated initializers when/std:c++20(or/std:c++latest) is active.2. Remove the GNU statement expressions
Why it compiles on Linux but not on Windows MSVC?
3. Replace
constexprinside the lambda[&]ET_INTERNAL_SWITCHwraps theNAMEin[&] { ... }(). The[&]capture means the lambda captures all local variables by reference, includingNAME.[&],NAMEis accessed via the closure's implicitthispointer — it is(*this).namein the closure's internal representation to capture variables by reference. Dereferencingthisis not a constant expression becausethisis a runtime pointer to the closure object, which is not a constant expression and only exists at runtime.Why it compiles on Linux but not on Windows MSVC?
constexprand its value is a compile-time constant, they allow it to be used as a constant expression inside the lambda, effectively treating the capture as a constant propagation rather than a runtime dereference. This is a quality-of-implementation extension beyond what the standard strictly requires.4. Replace the
__attribute__((visibility("default")))with corresponding MSVC-compatible syntax__declspec(dllexport)and__declspec(dllimport)to control symbol visibility when working with Windows DLLs.