首页 > 其他 > 详细

MISRA C:2012 8 Rules 8.5 Identifiers 标识符

时间:2019-10-13 17:00:30      阅读:90      评论:0      收藏:0      [点我收藏+]

3334 This declaration of ‘%s‘ hides a more global declaration.

extern int press;

void foo(void)
{
    float press;               /* Message 3334 */
}

3448 Declaration of typedef ‘%s‘ is not in a header file although it is used in a definition or declaration with external linkage.

typedef int TYPE;         /* Message 3448 */
extern TYPE foo(void);    /* Message 3447 */

extern TYPE foo(void)
{
    return 1;
}

1525 Object/function with external linkage has same identifier as another object/function with internal linkage.

file1.cpp
=======
extern int contr;    // Message 1525 

file2.cpp
=======
static int contr;    // Message 1525

这种写法是合法的,但是不建议这么写,如果上述代码写在同一个文件中,会报错。

1526 Object with no linkage has same identifier as another object/function with external linkage.重名错误

file1.cpp
=======
extern int remake;    // Message 1526 

file2.cpp
=======
void foo(void)
{
    int remake;      // Message 1526 
    ...
}

1527 Object/function with internal linkage has same identifier as another object/function with internal linkage.

file1.cpp
=======
static int cra;    // Message 1527

file2.cpp
=======
static int cra;    // Message 1527

这么写合法,但是不建议这么写

1528 Object with no linkage has same identifier as another object/function with internal linkage.

file1.cpp
=======
static int cra;    // Message 1528 

file2.cpp
=======
void foo(void)
{
    int cra;       // Message 1528 
    ...
}

 

MISRA C:2012 8 Rules 8.5 Identifiers 标识符

原文:https://www.cnblogs.com/focus-z/p/11666680.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!