用gcc警告 [英] Warnings with gcc

查看:96
本文介绍了用gcc警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

编译时收到警告:

#include< string.h>


int main(int argc,char ** argv)

{

char * s;

s = strdup(" a string");

返回0;

}


与gcc(GCC)3.3.5(Debian 1:3.3.5-8ubuntu2):


$ gcc -Wall -ansi warning.c

warning.c:在函数main中:

警告。 c:7:警告:隐式声明函数`strdup''

warning.c:7:警告:赋值使得整数指针没有

cast


有谁知道我怎么能压制这个警告?


如果我放一个演员:s =(char *)strdup(" a string") ;

我收到另一个警告信息:

warning.c:7:警告:隐式声明函数`strdup''


我不明白为什么会发生这种情况因为strdup声明在

string.h


谢谢,


Thibault Langlois

Hello,
I get a warning when I compile:
#include <string.h>

int main (int argc, char ** argv)
{
char * s;
s = strdup("a string");
return 0;
}

with gcc (GCC) 3.3.5 (Debian 1:3.3.5-8ubuntu2) :

$ gcc -Wall -ansi warning.c
warning.c: In function `main'':
warning.c:7: warning: implicit declaration of function `strdup''
warning.c:7: warning: assignment makes pointer from integer without a
cast

Does anybody knows how can I supress this warning ?

if I put a cast : s = (char *) strdup("a string");
I get another warning message:
warning.c:7: warning: implicit declaration of function `strdup''

I do not understand why this happens because strdup is declared in
string.h

Thanks,

Thibault Langlois

推荐答案

gcc -Wall -ansi warning.c

warning.c:在函数main中:

warning.c:7:警告:隐式声明函数`strdup''

warning.c:7:警告:赋值使整数指针没有

施放


有谁知道怎么能压制这个警告?


如果我放一个演员:s =(char *)strdup(" a string");

我收到另一个警告信息:

warning.c:7 :警告:隐式声明函数`strdup''


我不明白为什么会发生这种情况因为strdup在

string.h中声明


谢谢,


Thibault Langlois

gcc -Wall -ansi warning.c
warning.c: In function `main'':
warning.c:7: warning: implicit declaration of function `strdup''
warning.c:7: warning: assignment makes pointer from integer without a
cast

Does anybody knows how can I supress this warning ?

if I put a cast : s = (char *) strdup("a string");
I get another warning message:
warning.c:7: warning: implicit declaration of function `strdup''

I do not understand why this happens because strdup is declared in
string.h

Thanks,

Thibault Langlois




< th *************** @ di.fc.ul.pt>在消息中写道

news:11 ********************** @ g47g2000cwa.googlegr oups.com ...

<th***************@di.fc.ul.pt> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
你好,
我编译时会收到警告:
#include< string.h>

int main(int argc,char ** argv)
{*> char * s;
s = strdup(" a string");
返回0;
}
使用gcc( GCC)3.3.5(Debian 1:3.3.5-8ubuntu2):

Hello,
I get a warning when I compile:
#include <string.h>

int main (int argc, char ** argv)
{
char * s;
s = strdup("a string");
return 0;
}

with gcc (GCC) 3.3.5 (Debian 1:3.3.5-8ubuntu2) :


gcc -Wall -ansi warning.c
warning.c :在函数`main''中:
warning.c:7:警告:隐式声明函数`strdup''
warning.c:7:警告:赋值使整数指针不带
施放

有谁知道我怎么能压制这个警告?

如果我放一个演员:s =(char *)strdup(" a string"); <我收到另一个警告信息:
warning.c:7:警告:隐式声明函数`strdup''

我不明白为什么会发生这种情况因为strdup在
string.h
gcc -Wall -ansi warning.c
warning.c: In function `main'':
warning.c:7: warning: implicit declaration of function `strdup''
warning.c:7: warning: assignment makes pointer from integer without a
cast

Does anybody knows how can I supress this warning ?

if I put a cast : s = (char *) strdup("a string");
I get another warning message:
warning.c:7: warning: implicit declaration of function `strdup''

I do not understand why this happens because strdup is declared in
string.h




好​​吧,它不可能 - 除非编译器错了吗?


你确认它在[你的] string.h中吗?


你的预处理输出是否包含它?


它链接?


rayw



Well, it can''t be can it - unless the compiler''s wrong?

Have you confirmed that it''s in [your] string.h?

Does your preprocessed output contain it?

Does it link?

rayw


这篇关于用gcc警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆