我正在尝试在Windows 10上编译yaml-cpp。出于某种原因,atoi不是std命名空间的一部分,我无法弄清楚出了什么问题。谢谢!
cmake -G "MinGW Makefiles"
... (Makefile gets generated)
mingw32-make
C:\yaml-cpp-master\util\read.cpp: In function 'int main(int, char**)':
C:\yaml-cpp-master\util\read.cpp:54:11: error: 'atoi' is not a member of 'std'
N = std::atoi(argv[i]);
^
util\CMakeFiles\read.dir\build.make:62: recipe for target 'util/CMakeFiles/read.dir/read.cpp.obj' failed
答案 0 :(得分:2)
您有两种选择,包括atoi():
#include <stdlib.h>
,更加C友好,简称为atoi()
。#include <cstdlib>
,它更加C ++友好,可以同时引用atoi()
和std::atoi()
。答案 1 :(得分:0)
如果您发布了源代码会更有用,但要检查一件事:确保您实际上已经包含 <cstdlib>
。