ios 'strcmp' 未在此范围内声明

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9403975/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 16:57:35  来源:igfitidea点击:

‘strcmp’ was not declared in this scope

iosg++makefiletoolchaingnu-toolchain

提问by Connor

I'm working on building the ios toolchain with this tutorial. When I run the command make ENABLE_OPTIMIZED=1 I get this output.

我正在使用本教程构建 ios 工具链。当我运行命令 make ENABLE_OPTIMIZED=1 时,我得到了这个输出。

llvm[0]: Reconfiguring with /home/connor/llvm-svn/configure
config.status: creating Makefile.config
config.status: creating llvm.spec
config.status: creating docs/doxygen.cfg
config.status: creating tools/llvm-config/llvm-config.in
config.status: creating include/llvm/Config/config.h
config.status: creating include/llvm/Support/DataTypes.h
config.status: include/llvm/Support/DataTypes.h is unchanged
config.status: creating include/llvm/ADT/hash_map
config.status: include/llvm/ADT/hash_map is unchanged
config.status: creating include/llvm/ADT/hash_set
config.status: include/llvm/ADT/hash_set is unchanged
config.status: creating include/llvm/ADT/iterator
config.status: include/llvm/ADT/iterator is unchanged
config.status: executing setup commands
config.status: executing Makefile commands
config.status: executing Makefile.common commands
config.status: executing examples/Makefile commands
config.status: executing lib/Makefile commands
config.status: executing runtime/Makefile commands
config.status: executing test/Makefile commands
config.status: executing test/Makefile.tests commands
config.status: executing tools/Makefile commands
config.status: executing utils/Makefile commands
config.status: executing projects/Makefile commands
config.status: executing bindings/Makefile commands
config.status: executing bindings/ocaml/Makefile.ocaml commands
make[1]: Entering directory `/home/connor/llvm-svn/lib/System'
llvm[1]: Compiling Alarm.cpp for Release build 
llvm[1]: Compiling Disassembler.cpp for Release build 
Disassembler.cpp: In function ‘std::string llvm::sys::disassembleBuffer(uint8_t*, size_t, uint64_t)':
Disassembler.cpp:44:12: warning: variable ‘bits' set but not used [-Wunused-but-set-variable]
llvm[1]: Compiling DynamicLibrary.cpp for Release build 
DynamicLibrary.cpp: In static member function ‘static void* llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(const char*)':
DynamicLibrary.cpp:178:5: error: ‘strcmp' was not declared in this scope
DynamicLibrary.cpp:178:5: error: ‘stderr' was not declared in this scope
DynamicLibrary.cpp:179:5: error: ‘strcmp' was not declared in this scope
DynamicLibrary.cpp:179:5: error: ‘stdout' was not declared in this scope
DynamicLibrary.cpp:180:5: error: ‘strcmp' was not declared in this scope
DynamicLibrary.cpp:180:5: error: ‘stdin' was not declared in this scope
make[1]: *** [/home/connor/llvm-svn/lib/System/Release/DynamicLibrary.o] Error 1
make[1]: Leaving directory `/home/connor/llvm-svn/lib/System'
make: *** [all] Error 1

I'm not sure what to make of this and my googling hasn't helped very much.

我不知道该怎么做,我的谷歌搜索也没有太大帮助。

回答by jcubic

strcmp function is declared in string.h try to put

strcmp 函数在 string.h 中声明尝试放入

#include <string.h> 

in DynamicLibrary.cpp and stderr is defained in stdio.h so put that too

在 DynamicLibrary.cpp 和 stderr 在 stdio.h 中定义所以也放

#include <stdio.h>

From time to time I found open source code with missing header files as well.

我不时发现缺少头文件的开源代码。

UPDATE:

更新

If you have different name you can search include directory,

如果你有不同的名字,你可以搜索包含目录,

in real GNU/Linux bash you can use this to search for function:

在真正的 GNU/Linux bash 中,您可以使用它来搜索功能:

find /usr/include -type f | xargs grep ' strcmp\s*\('

and this for variable:

这对于变量:

find /usr/include -type f | xargs grep '[\s*]stdin\s*;'

on Git Bash on Windows there is /include and /mingw64/includedirectories but on my installation there were only ImageMagick header files and /mingw64/include/gnumake.h

在Git的击在Windows上有/ include和/mingw64/include目录,但在我的安装有只ImageMagick的头文件和/mingw64/include/gnumake.h