在代码的注释中经常看到//lint !e1554 是什么意思?
答案:1 悬赏:0 手机版
解决时间 2021-11-27 08:08
- 提问者网友:饥饿走向夜
- 2021-11-26 18:29
在代码的注释中经常看到//lint !e1554 是什么意思?
最佳答案
- 五星知识达人网友:思契十里
- 2021-11-26 20:01
有一些公司对代码质量检查非常严格,通常会要求所有编写完成的代码在编译的时候一个告警(Warning)信息都不能有,所以就涉及到告警检查和消除的问题。通常会用一个叫PC-Lint的静态代码检查工具来对代码进行扫描,然后列出有错误或者告警的地方,然后由程序员进行修改。通常,某个告警被修改之后,会在修改的地方注明一下为什么修改,所以,//lint !e1554的意思大概就是此处修改了PC-lint检查出来的1554号告警信息。通常来说,1554号告警只存在于C++代码中,C没有这么多告警号,具体,可以去找PC-lint相关的资料来看看。
补充一下1554告警说明:
1554 Direct pointer copy of member 'Symbol' within copy
constructor: 'Symbol' -- In a copy constructor a pointer
was merely copied rather than recreated with new storage.
This can create a situation where two objects have the
same data and this, in turn, causes problems when these
objects are deleted or modified. For example, the
following class will draw this warning:
class X
{
char *p;
X( const X & x )
{ p = x.p; }
...
};
Here, member p is expected to be recreated using new or
some variant.
其实就是拷贝构造函数里所谓的“浅拷贝”问题,需要重新分配空间,而不是直接拷贝指针。
补充一下1554告警说明:
1554 Direct pointer copy of member 'Symbol' within copy
constructor: 'Symbol' -- In a copy constructor a pointer
was merely copied rather than recreated with new storage.
This can create a situation where two objects have the
same data and this, in turn, causes problems when these
objects are deleted or modified. For example, the
following class will draw this warning:
class X
{
char *p;
X( const X & x )
{ p = x.p; }
...
};
Here, member p is expected to be recreated using new or
some variant.
其实就是拷贝构造函数里所谓的“浅拷贝”问题,需要重新分配空间,而不是直接拷贝指针。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯