Reputation: 455
I'm trying to use gcd
function from #include <numeric>
in Visual Studio 2019 (Community version). However, using namespace std
, visual studio just says that "gcd" is undefined. Based on my research, I'm supposed to change the C++ version. However, in the normal settings I can't find "Configuration Properties" and right clicking on the project in the solution explorer to then select properties, just shows me an empty window (see emtpy-property-window picture).
Background info:
namespace std
and #inlcude <iostream>
so far (with no problem)#include <numeric>
and then trying to use gcd(x,y)
, I get the previous described error-hintnamespace std
, even though that's already added.Any idea to solve either problem?
Upvotes: 1
Views: 1478
Reputation: 82451
The gcd
function was added in C++17. You probably haven't set the appropriate standard in your project settings. At least this is the exact issue you'll get when trying to use std::filesystem::...
with an older C++ standard with Visual Studio. (The file system library was added in C++17 too.)
In the project properties Configuration Properties
> General
> C++ Language Standard
should be set to ISO C++17 Standard (/std::c++17)
to make the code compile.
You can open the project properties by selecting Properties
in the context menu for the target shown in the solution explorer btw; the properties shown in your screenshot just display some very basic information about the selected item.
Upvotes: 2