Does someone have any chance to make the C++ IDE on macOS Sonoma 14.5 (M3 Macbook) recognize std::execution::par
from #include <execution>
?
What I want is to simply compile this chunk of code:
std::transform(
std::execution::par,
input.begin() + start,
input.begin() + end,
output.begin() + start,
[](float x) {
return pow(x, 2);
}
);
Notably, I can easily compile it on Microsoft Visual Studio Community Edition on Windows 10 and 11 using C++17 language standard.
However when I select the same standard on Xcode or CLion, or VS Code, these IDEs cannot recognize and build that code part.
What I have tried in different IDEs for MacOS:
It appears that the Apple's default C++ compiler clang has a partial support of the C++17 features according to this table.
The correct way to make it actually compile the code with std::execution::par feature is just to append the -fexperimental-library flag as follows:
clang++ main.cpp -std=c++17 -stdlib=libc++ -fexperimental-library
The solution regarding that undocumented but mandatory compilation rule was founded in an issue #65125 of the llvm-project thanks to Nikolas Klauser!
To force the IntelliSence to understand experimental compiler features, the compiler flag should be appended into the compilerArgs array in the c_cpp_properties.json when using the Visual Studio Code IDE:
And the code editor will properly recognize the std::execution::par:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With