Xcode 7.2 找不到 c++ std::pair
Xcode 7.2 can't find c++ std::pair
首先,我在OSX 10.11.2 上使用Xcode 7.2。在我的 main.cpp 文件中,std 库运行良好。但是,每当我尝试在任何其他 C++ 文件中使用它时,我都会得到 unexpected unqualified-id
.
我有以下文件:
main.cpp (std is working in it)
algo.hpp (std is not working in it)
algo.cpp (std is not working in it)
为什么部署目标 OSX 10.11 在我的所有文件中都找不到标准 c++ 库?
例如我的头文件algo.hpp
#ifndef algo_hpp
#define algo_hpp
std::pair<unsigned int, unsigned int> pgcdFB(const int m,const int n);
std::pair<unsigned int, unsigned int> euclide(const int m, const int n);
unsigned int fibonacci(const unsigned int i);
#endif /* algo_hpp */
在我使用 std 的每一行我得到 undeclared identifier 'std
您必须包含正确的 headers,您只是忘记了 #include <utility>
,因为您使用的是 std::pair
。 (而且似乎没有理由在这里包括 stdio.h)
首先,我在OSX 10.11.2 上使用Xcode 7.2。在我的 main.cpp 文件中,std 库运行良好。但是,每当我尝试在任何其他 C++ 文件中使用它时,我都会得到 unexpected unqualified-id
.
我有以下文件:
main.cpp (std is working in it)
algo.hpp (std is not working in it)
algo.cpp (std is not working in it)
为什么部署目标 OSX 10.11 在我的所有文件中都找不到标准 c++ 库?
例如我的头文件algo.hpp
#ifndef algo_hpp
#define algo_hpp
std::pair<unsigned int, unsigned int> pgcdFB(const int m,const int n);
std::pair<unsigned int, unsigned int> euclide(const int m, const int n);
unsigned int fibonacci(const unsigned int i);
#endif /* algo_hpp */
在我使用 std 的每一行我得到 undeclared identifier 'std
您必须包含正确的 headers,您只是忘记了 #include <utility>
,因为您使用的是 std::pair
。 (而且似乎没有理由在这里包括 stdio.h)