首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >“‘strcmp”未在此范围内声明

“‘strcmp”未在此范围内声明
EN

Stack Overflow用户
提问于 2012-02-23 06:15:36
回答 2查看 56.2K关注 0票数 18

我正在用这个tutorial构建ios工具链。当我运行命令make ENABLE_OPTIMIZED=1时,我得到以下输出。

代码语言:javascript
运行
复制
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

我不知道这是怎么回事,我的谷歌搜索也没有多大帮助。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-02-23 06:36:48

strcmp函数在string.h中声明。h尝试将

代码语言:javascript
运行
复制
#include <string.h> 

在DynamicLibrary.cpp中定义了stderr,而在stdio.h中定义了stderr

代码语言:javascript
运行
复制
#include <stdio.h>

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

更新

如果您有不同名称,可以搜索包含目录,

在真实的GNU/Linux bash中(应该也可以与Windows10WSL一起使用),您可以使用以下代码来搜索函数:

代码语言:javascript
运行
复制
find /usr/include -type f | xargs grep ' strcmp\s*\('

变量是这样的:

代码语言:javascript
运行
复制
find /usr/include -type f | xargs grep '[\s*]stdin\s*;'

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

票数 27
EN

Stack Overflow用户

发布于 2020-09-29 11:35:42

在C++中编码时也会发生同样的错误。在这种情况下,包括cstring库来解决错误。

代码语言:javascript
运行
复制
#include<cstring>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9403975

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档