c - 我如何使用 strcastr()?

标签 c string gcc

#include <string.h>但是当我调用strcasestr(src, search);我收到以下错误消息 implicit declaration of function ‘strcasestr’ .我如何编译:gcc-4.6 -Wall -lsqlite3 -lunac -Werror -O2 -o foo.out foo.c如何解决这个问题?提前致谢。

最佳答案

corresponding manpage 中所述, 自 strcasestr是非标准扩展,您必须 #define _GNU_SOURCE #include <string.h> 之前 在任何 #include 之前(其他文件可能已经包含 <string.h> ,感谢@Cubbi 指出这个潜在问题);这也可以通过指定 -D_GNU_SOURCE 轻松完成。在编译器命令行上。

关于c - 我如何使用 strcastr()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9935642/

相关文章:

c - 未显示 c 中结构数组的正确值

python - 使用 ctypes 时,C 函数中的 printf() 在 Python 中输出错误结果

sql - 在 Oracle 中快速生成连接字符串的方法

c - 反汇编c代码中的冗余操作

c - 共享库编译 gcc

python - 如何将 4 字节 IEEE(小端)float 二进制表示转换为 float

在 C 中从数组调用函数

r - 在 R 中的多个字符串中选择可变长度字符串

c++ - CPP : Parsing String Stream is too slow

c++ - GCC 中的 OpenHMPP