warning: implicit declaration of function导致core
生活随笔
收集整理的這篇文章主要介紹了
warning: implicit declaration of function导致core
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
centos上使用gcc編譯某程序得到warning:
implicit declaration of function
同時寫了一個測試程序用到c++庫, 因此使用g++編譯。
測試程序無問題。? 原程序使用gcc編譯得到warning沒在意, 使用起來后一直莫名其妙的core掉。? 開始以為是其他問題而忽略了該warning。? 而該core恰恰是由此warning產生的。
因為用到了 strcasestr, 需要
#define _GNU_SOURCE?? //這個可能多余、在網上查到的
#define __USE_GNU????????? //這個必需。 見系統的 include/相應的文件下。
#include <string.h>????????????? //聲明該函數的頭文件
__USE_GNU 沒有定義該宏時就會產生上述warning、 gcc會core。? 定義之后就無問題了。
同時發現gcc中 min也未定義。。
總結
以上是生活随笔為你收集整理的warning: implicit declaration of function导致core的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: myocr
- 下一篇: jdk-ant-sphnix4安装