警告:可能使用空指针 [英] Warning : Possible use of null pointer

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

问题描述

大家好

i wana删除我在

codcomilation期间收到的这个警告。


警告是 -

可能使用空指针''PnoSytGenericTest :: _ response''

左参数运算符'' - >''


和与此警告相关的部分代码 -


void PnoSytGenericTest :: initResponse()

{

ENTER_METHOD (SYT_TEST_MGR,PnoSytGenericTest :: initResponse);


_response = new AcdMessage();

_response-> header(_data-> header ());

(_response-> header())。cmdId [0] .cmdId = Acd :: CMD_RSP;


RETURN_METHOD(" SYT_TEST_MGR");

}


帮助我的朋友......

Hi guys
i wana remove this warning which i am getting during my
codcomilation.

the warning is -
Possible use of null pointer ''PnoSytGenericTest::_response'' in
left argument to operator ''->''

and the part of the code related to this warning-

void PnoSytGenericTest::initResponse()
{
ENTER_METHOD("SYT_TEST_MGR", PnoSytGenericTest::initResponse);

_response = new AcdMessage();
_response->header(_data->header());
(_response->header()).cmdId[0].cmdId = Acd::CMD_RSP;

RETURN_METHOD("SYT_TEST_MGR");
}

help me out friends...

推荐答案

惠普写道:
大家好
我想删除这个警告,我在
codcomilation期间得到了这个警告。

警告是 -
可能使用空指针''PnoSytGenericTest :: _ response''在左边的参数中给运算符'' - >''

和部分与此警告相关的代码 -

void PnoSytGenericTest :: initResponse()
{
ENTER_METHOD(" SYT_TEST_MGR",PnoSytGenericTest :: initResponse);
_response = new AcdMessage();
_response-> header(_data-> header());
(_ response-> header())。cmdId [0] .cmdId = Acd: :CMD_RSP;

RETURN_METHOD(" SYT_TEST_MGR");
}

帮助我的朋友......
Hi guys
i wana remove this warning which i am getting during my
codcomilation.

the warning is -
Possible use of null pointer ''PnoSytGenericTest::_response'' in
left argument to operator ''->''

and the part of the code related to this warning-

void PnoSytGenericTest::initResponse()
{
ENTER_METHOD("SYT_TEST_MGR", PnoSytGenericTest::initResponse);

_response = new AcdMessage();
_response->header(_data->header());
(_response->header()).cmdId[0].cmdId = Acd::CMD_RSP;

RETURN_METHOD("SYT_TEST_MGR");
}

help me out friends...



您使用的编译器是什么,是否启用了例外?在

标准C ++中,_response不能为null,因为new会在失败时抛出

异常。如果这个

不正确或者你已经禁用异常,那么你应该检查

是否为空。请参阅此常见问题解答:

http://www.parashift.com/c++-faq-lit....html#faq-16.6


干杯! --M



What compiler are you using and do you have exceptions enabled? In
standard C++, _response could not be null because new throws an
exception on failure. On non-conformant implementations where this
isn''t true or if you have disabled exceptions, then you should check
for null. See this FAQ:

http://www.parashift.com/c++-faq-lit....html#faq-16.6

Cheers! --M


嘿Mlimber

i我正在使用MRI(Microtech research INC。)

编译器。

我启用了异常。

但是我没想到新的失败我正在接受这种调整。

hey Mlimber
i am using MRI (Microtech research INC.)
compiler.
and i have exception enabled.
but i dont think on failure of new i am getting this warrning.


惠普写道:
我删除了这个警告,我在
codcomilation期间得到了这个警告。


什么是'codcomilation"?这是你表演的某种仪式吗?或者

是你在学校考试(考试)?我的字典确实

不包含那个词......我知道''cod''是一种鱼......你是在谈论在鳕鱼上做点什么吗? ?古亭?清洁?

它死了还是活着?可能没关系...

警告是 -
可能使用空指针''PnoSytGenericTest :: _ response''在
左边的参数中给运营商'' - >''

以及与此警告相关的部分代码 -

void PnoSytGenericTest :: initResponse()

ENTER_METHOD(" ; SYT_TEST_MGR",PnoSytGenericTest :: initResponse);

_response = new AcdMessage();
_response-> header(_data-> header());
(_response - > header())。cmdId [0] .cmdId = Acd :: CMD_RSP;

RETURN_METHOD(" SYT_TEST_MGR");
}


什么*行*是警告?你有可能使用这样的旧编译器,它可以返回一个空指针作为''new''的结果。

如果那是''所以,升级你的编译器。显然它认为

''_ response''变量可以成为空指针,这是非标准的行为。你可以通过这样做来解决这个问题


_response = new AcdMessage();

if(_response){

...

}

RETURN_METHOD ...

帮助我的朋友......
i wana remove this warning which i am getting during my
codcomilation.
What''s "codcomilation"? Is that some kind of rite you perform? Or
is that an exam (test) you''re taking at school? My dictionary does
not contain that word... I know ''cod'' is a kind of fish... Are you
talking about performing something on a cod? Gutting? Cleaning?
Is it dead or alive? Probably doesn''t matter...
the warning is -
Possible use of null pointer ''PnoSytGenericTest::_response'' in
left argument to operator ''->''

and the part of the code related to this warning-

void PnoSytGenericTest::initResponse()
{
ENTER_METHOD("SYT_TEST_MGR", PnoSytGenericTest::initResponse);

_response = new AcdMessage();
_response->header(_data->header());
(_response->header()).cmdId[0].cmdId = Acd::CMD_RSP;

RETURN_METHOD("SYT_TEST_MGR");
}
What *line* is the warning for? It is possible that you''re using such
an old compiler that can return a null pointer as a result of ''new''.
If that''s so, upgrade your compiler. Apparently it thinks that the
''_response'' variable can become a null pointer, which is non-standard
behaviour. You could work around this by doing

_response = new AcdMessage();
if (_response) {
...
}
RETURN_METHOD...
help me out friends...




没什么好继续的,只是为了让你知道。


V



Not much to go on, just to let you know.

V


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

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