Reputation: 5941
What I am trying to achieve is pretty simple: I just want to use C++17 features in a Visual Studio Android project.
I have just taken one of the Visual Studio examples (New Project --> Visual C++ --> Cross Platform --> select any of these) and added an #include <optional>
in one of the source files. Furthermore, I've set the following configuration properties:
Under Configuration Properties --> General:
Target API Level
to a more recent oneUse of STL
to LLVM libc++ shared library
, but I've tried several options thereUnder Configuration Properties --> C++ --> Language:
C++ Language Standard
to C++17 (-std=c++1z)
The result is always the same: An error message during building which says:
'optional' file not found
Other C++17 includes don't work either (e.g. 'variant').
What's going on here? How can a Visual Studio (sample) projects be configured so that C++17 language features can be used?
Upvotes: 1
Views: 501
Reputation: 105
I had the same problem and solved it for a few libraries by simply using Visual Studio 2019. All presets can be taken over there, apart from the C++ Language Standard (-std=c++1z).
The following libraries can now be included:
#include <variant>
#include <optional>
#include <string_view>
#include <any>
And the rest still can not be included:
#include <memory_resource> // error
#include <charconv> // error
#include <execution> // error
#include <filesystem> // error
Upvotes: 1